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
# nov@tov ~$ ruby -v | |
# ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1] | |
module IncludeMe | |
def say(message: "Hello") | |
puts "#{message} from IncludeMe" | |
end | |
end | |
module PrependMe | |
def say(message: "Hello") | |
puts "#{message} from PrependMe" | |
super | |
end | |
end | |
class Base | |
prepend PrependMe | |
include IncludeMe | |
def say(message: "Hello") | |
puts "#{message} from Base" | |
super | |
end | |
end | |
b = Base.new | |
b.say message: 'Yeah!' | |
# => | |
# Yeah! from PrependMe | |
# Hello from Base | |
# Hello from IncludeMe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment