-
-
Save paulsonkoly/9806c7bd32ec1a3df28bf19788a0e30d to your computer and use it in GitHub Desktop.
singleton
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 Foo | |
def initialize | |
singleton_class.class_eval { def foo; :bar; end } | |
singleton_class.class_eval do | |
alias_method :f_o_o, :foo | |
end if respond_to? :foo | |
end | |
end | |
Foo.new.f_o_o # => :bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment