Skip to content

Instantly share code, notes, and snippets.

@sandro
Created January 26, 2009 22:32
Show Gist options
  • Save sandro/53011 to your computer and use it in GitHub Desktop.
Save sandro/53011 to your computer and use it in GitHub Desktop.
capture inherited method before redefining it
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