#!/usr/bin/env ruby | |
class A | |
def b | |
'b' | |
end | |
end | |
module X | |
def b | |
"#{super}x" | |
end | |
end | |
module Y | |
def self.included base | |
base.class_eval do | |
alias_method :b_without_y, :b | |
alias_method :b, :b_with_y | |
end | |
end | |
def b_with_y | |
"#{b_without_y}y" | |
end | |
end | |
case ARGV[0] | |
when '--prepend' # bx | |
A.prepend X | |
when '--alias' # by | |
A.include Y | |
when '--both' # SystemStackError | |
A.prepend X | |
A.include Y | |
when '--flip' # byx | |
A.include Y | |
A.prepend X | |
end | |
puts A.new.b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment