Created
March 29, 2016 09:09
-
-
Save unak/f36def728e8c5411eff8 to your computer and use it in GitHub Desktop.
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
class A | |
def initialize | |
p :A | |
end | |
end | |
class B < A | |
def initialize | |
p :B | |
end | |
end | |
B.new # => :B | |
module M | |
def self.prepended(klass) | |
@@initializeA = klass.ancestors[2].instance_method(:initialize) | |
end | |
def initialize | |
super | |
@@initializeA.bind(self).call | |
end | |
end | |
class B < A | |
prepend M | |
end | |
B.new # => :B and :A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment