Created
January 26, 2009 22:32
-
-
Save sandro/53011 to your computer and use it in GitHub Desktop.
capture inherited method before redefining it
This file contains hidden or 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 self.hi | |
'hi from A' | |
end | |
end | |
class B < A | |
class << self | |
alias_method :b, :hi | |
end | |
def self.hi | |
'hi from B' | |
end | |
end | |
puts B.hi | |
puts B.b | |
#hi from B | |
#hi from A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment