Created
February 12, 2014 20:57
-
-
Save phiggins/8964349 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 Taco | |
> def self.delicious? ; true ; end | |
> singleton_class.send :alias_method, :yummy?, :delicious? | |
> end | |
=> #<Class:Taco> | |
> Taco.yummy? | |
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to use
singleton_class.send
because alias_method is private. Putting the alias in aclass << self
block has the advantage of working in old rubies.