public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.