Skip to content

Instantly share code, notes, and snippets.

@paulsonkoly
Created February 8, 2021 12:28
Show Gist options
  • Save paulsonkoly/9806c7bd32ec1a3df28bf19788a0e30d to your computer and use it in GitHub Desktop.
Save paulsonkoly/9806c7bd32ec1a3df28bf19788a0e30d to your computer and use it in GitHub Desktop.
singleton
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