Sometimes, when building a plugin, you have to extend Rails behaviour using alias_method_chain.
So you do, on the included module:
[ruby]
…
def self.included(base)
base.send :include InstanceMethods
base.class_eval do
alias_method_chain :method_i_want_to_extend, :my_feature
end
end
module InstanceMethods
def method_i_want_to_extend_with_my_feature(args)
(do something or not…)
method_i_want_to_extend_without_my_feature(args)
(do something or not…)
end
end
…
[/ruby]
What if the method you are extending is a class method?
Simple, just use the singleton class:
[ruby]
…
def self.included(base)
base.extend ClassMethods
base.class_eval do
class