class Her::Model::Associations::AssociationProxy
Public Class Methods
install_proxy_methods(target_name, *names)
click to toggle source
@private
# File lib/her/model/associations/association_proxy.rb, line 7 def self.install_proxy_methods(target_name, *names) names.each do |name| module_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name}(*args, &block) #{target_name}.send(#{name.inspect}, *args, &block) end RUBY end end
new(association)
click to toggle source
@private
# File lib/her/model/associations/association_proxy.rb, line 21 def initialize(association) @_her_association = association end
Public Instance Methods
association()
click to toggle source
# File lib/her/model/associations/association_proxy.rb, line 25 def association @_her_association end
method_missing(name, *args, &block)
click to toggle source
@private
# File lib/her/model/associations/association_proxy.rb, line 30 def method_missing(name, *args, &block) if :object_id == name # 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