Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extending with ModA
- this is method bar of ModB
- extending with ModB
- this is method bar of ModB
- module ModA
- extend ActiveSupport::Concern
- module ClassMethods
- def bar
- puts "this is method bar of ModA"
- end
- # grab UnboundMethod of ModA::ClassMethods::bar
- a_bar = instance_method(:bar)
- # using define_method to capture a_bar
- define_method :extend_with_mod_a do
- puts "extending #{self} with ModA"
- # invoke ModA::ClassMethods::bar properly bound to the class being extended/included with ModA
- a_bar.bind(self).call
- end
- end
- end
- ActiveRecord::Base.send :prepend, ExtModule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement