I have a Ruby object (ActiveRecord object in particular) with a name User. It responds to type methods find_by_id, find_by_auth_tokenetc. However, these are not methods that are defined through defor define_method. Instead, they are dynamic methods that are processed through method_missing.
I would like to get a link to one of these methods using Object#method, for example:
User.method(:find_by_auth_token)
This does not seem to work. The best solution I came up with is:
proc { |token| User.find_by_auth_token(token) }
Is there any other way to use a wrapper method like this? Can't I really use Object#methodfor dynamic methods?
source
share