samedi 14 mars 2015

ActiveRecord::Base extending with ClassMethods module


Vote count:

0




I have a code like this in rails console:



module Taggable
extend ActiveSupport::Concern
module ClassMethods
def taggable?
false
end
end
end



When I run: ActiveRecord::Base.send :include, Taggable. I see that the method taggable? will become instance_methods of singleton_class: ActiveRecord::Base.singleton_class.instance_methods.include? :taggable? # => true.


But when I run ActiveRecord::Base.extend Taggable. I don't know where is the method taggable? in? ActiveRecord::Base.singleton_class.methods.include? :taggable? # => false



Please help me understand it.



asked 29 secs ago







ActiveRecord::Base extending with ClassMethods module

Aucun commentaire:

Enregistrer un commentaire