Skip to content

Instantly share code, notes, and snippets.

@peter
Created February 25, 2010 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter/314358 to your computer and use it in GitHub Desktop.
Save peter/314358 to your computer and use it in GitHub Desktop.
class Author
def invoke_inside(method, *args)
self.send(method, *args)
end
end
author = Article.first.author
def author.foobar
"foobar"
end
author.object_id # => 9969140
author.respond_to?(:foobar) # => true
author.class # => Author
author.invoke_inside(:object_id) # => 9952490
author.invoke_inside(:respond_to?, :foobar) # => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment