Created
April 5, 2012 22:52
-
-
Save soulcutter/2314814 to your computer and use it in GitHub Desktop.
Overriding instance methods
This file contains 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 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