Skip to content

Instantly share code, notes, and snippets.

@ngpestelos
Created September 29, 2013 04:14
Show Gist options
  • Select an option

  • Save ngpestelos/6749288 to your computer and use it in GitHub Desktop.

Select an option

Save ngpestelos/6749288 to your computer and use it in GitHub Desktop.
eigenclass
# see Metaprogramming Ruby, p. 107
obj = Object.new
eigenclass = class << obj
self
end
eigenclass.class # Class
def obj.my_singleton_method; end
eigenclass.instance_methods.grep(/my_/) # ["my_singleton_method"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment