-
-
Save 3014zhangshuo/798df3ca92aac2c568af8ec6f1364af3 to your computer and use it in GitHub Desktop.
Append features vs included
This file contains hidden or 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
module A | |
def self.included(target) | |
v = target.instance_methods.include?(:method_name) | |
puts "in included: #{v}" | |
end | |
def self.append_features(target) | |
v = target.instance_methods.include?(:method_name) | |
puts "in append features before: #{v}" | |
super | |
v = target.instance_methods.include?(:method_name) | |
puts "in append features after: #{v}" | |
end | |
def method_name | |
end | |
end | |
class X | |
include A | |
end |
This file contains hidden or 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
in append features before: false | |
in append features after: true | |
in included: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment