Method: NinjaModel::Associations::AssociationProxy#method_missing

Defined in:
lib/ninja_model/associations/association_proxy.rb

#method_missing(method, *args) ⇒ Object (private)



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/ninja_model/associations/association_proxy.rb', line 93

def method_missing(method, *args)
  if load_target
    unless @target.respond_to?(method)
      message = "undefined method '#{method.to_s}' for \"#{@target}\":#{@target.class.to_s}"
      raise NoMethodError, message
    end

    if block_given?
      @target.send(method, *args) { |*block_args| yield(*block_args) }
    else
      @target.send(method, *args)
    end
  end
end