Skip to content

Instantly share code, notes, and snippets.

@paneq
Created August 6, 2012 10:01
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paneq/3273049 to your computer and use it in GitHub Desktop.
Save paneq/3273049 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