Skip to content

Instantly share code, notes, and snippets.

@unak
Created March 29, 2016 09:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unak/f36def728e8c5411eff8 to your computer and use it in GitHub Desktop.
Save unak/f36def728e8c5411eff8 to your computer and use it in GitHub Desktop.
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