class NinjaModel::Associations::CollectionProxy

Public Class Methods

new(association) click to toggle source
# File lib/ninja_model/associations/collection_proxy.rb, line 12
def initialize(association)
  @association = association
end

Public Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/ninja_model/associations/collection_proxy.rb, line 26
def method_missing(method, *args, &block)
  if target.respond_to?(method) || (!proxy_association.klass.respond_to?(method) && Class.respond_to?(method))
    if load_target
      if target.respond_to?(method)
        target.send(method, *args, &block)
      else
        begin
          super
        rescue NoMethodError => e
          raise e, e.message.sub(/ for #<.*$/, "via proxy for #{target}")
        end
      end
    end
  else
    scoped.send(method, *args, &block)
  end
end
proxy_association() click to toggle source
# File lib/ninja_model/associations/collection_proxy.rb, line 16
def proxy_association
  @association
end
respond_to?(name, include_private = false) click to toggle source
Calls superclass method
# File lib/ninja_model/associations/collection_proxy.rb, line 20
def respond_to?(name, include_private = false)
  super ||
    (load_target && target.respond_to?(name, include_private)) ||
    proxy_association.klass.respond_to?(name, include_private)
end