Skip to content

Instantly share code, notes, and snippets.

@soulcutter
Created April 5, 2012 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soulcutter/2314814 to your computer and use it in GitHub Desktop.
Save soulcutter/2314814 to your computer and use it in GitHub Desktop.
Overriding instance methods
module WizardSkills
module InstanceMethods
def trick
super
puts "The #{self.class} turned a man into a rabbit"
end
end
end
module MagicianSkills
def trick
puts "The #{self.class} pulled a rabbit out of a hat"
end
end
class Magician
def trick
puts "I don't want this"
end
end
class Magician
include MagicianSkills
include WizardSkills::InstanceMethods
end
Magician.new.trick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment