title: is it possible to programmatically determine what object a method is being delegated to in ruby?
body: <p>i have a set of objects, some of which have an organization_id attribute, and others of which delegate organization_id.</p>
  
  <p>for example:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>i would like a means by which to programmatically determine which class of object the organization_id is being delegated to so that i could do something like the following</p>
  
  <pre><code>def find_organization_id_source(object)
     object.organization_id.method_im_hoping_exists
  end
  $ find_organization_id_source(@program)
  &gt;&gt; Department
  $ find_organization_id_source(@users_role)
  &gt;&gt; Role
  </code></pre>