is it possible to programmatically determine what object a method is being delegated to in ruby? -


i have set of objects, of have organization_id attribute, , others of delegate organization_id.

for example:

class department   belongs_to :organization end class program   belongs_to :department   delegate :organization_id, to: :department end  class role   belongs_to :organization end class usersrole   belongs_to :role   delegate :organization_id, to: :role end 

i means programmatically determine class of object organization_id being delegated following

def find_organization_id_source(object)    object.organization_id.method_im_hoping_exists end $ find_organization_id_source(@program) >> department $ find_organization_id_source(@users_role) >> role 

it not possible. can seen in source of active_support/core_ext/module/delegation.rb, rails creates new method internally invoke delegated method.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -