Skip to content

Instantly share code, notes, and snippets.

@dholdren
Created April 27, 2017 15:15
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 dholdren/58250ceb791f04b3230c9d79da430b6f to your computer and use it in GitHub Desktop.
Save dholdren/58250ceb791f04b3230c9d79da430b6f to your computer and use it in GitHub Desktop.
#I want to call @request.method(:remote_ip) to find out where it's defined using Object#method method.
#But that's been overriden so that you can find out which HTTP verb was used (GET/POST/etc)
module ObjectMethod
def object_method(name)
Object.instance_method(:method).bind(self).call(name)
end
end
Object.include(ObjectMethod)
#request.method(:remote_ip)
#=>
#meth = request.object_method(:remote_ip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment