Skip to content

Instantly share code, notes, and snippets.

@3014zhangshuo
Forked from paneq/implementation.rb
Created July 11, 2018 02:14
Show Gist options
  • Save 3014zhangshuo/798df3ca92aac2c568af8ec6f1364af3 to your computer and use it in GitHub Desktop.
Save 3014zhangshuo/798df3ca92aac2c568af8ec6f1364af3 to your computer and use it in GitHub Desktop.
Append features vs included
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
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