This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Ideas stolen from lograge and brought to Rails 2.3 | |
# https://github.com/mattmatt/lograge/blob/master/lib/lograge/log_subscriber.rb | |
# | |
module ImprovedControllerLogging | |
def self.included(base) | |
base.alias_method_chain :log_processing, :fixup | |
base.inject_alias_method_chain :perform_action, | |
:perform_action_with_benchmark, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
# Use this to replace a method in an alias_method_chain | |
def inject_alias_method_chain(target, method_to_replace, method_to_use) | |
method_instance_to_replace = instance_method(method_to_replace) | |
meths = (private_instance_methods | instance_methods).sort.grep(/^#{target}/) | |
found = meths.detect do |m| | |
m != method_to_replace.to_s && instance_method(m) == method_instance_to_replace | |
end | |
if found | |
alias_method found, method_to_use |
NewerOlder