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

php - Extract Text from HTTP referer -

Receive udp packets in android gstreamer -

authentication - ASP.NET Core 1.0. Bearer Token, cannot access custom claims -