public

  • Download Gist
behavior_of_super_with_keyword_args_in_2_0.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.