Class: Her::Model::Associations::AssociationProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/her/model/associations/association_proxy.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/her/model/associations/association_proxy.rb', line 30

def method_missing(name, *args, &block)
  if name == :object_id # avoid redefining object_id
    return association.fetch.object_id
  end

  # create a proxy to the fetched object's method
  AssociationProxy.install_proxy_methods 'association.fetch', name

  # resend message to fetched object
  __send__(name, *args, &block)
end

Instance Method Details

#associationObject



25
26
27
# File 'lib/her/model/associations/association_proxy.rb', line 25

def association
  @_her_association
end