Class: Mongoid::Association::Referenced::HasManyThrough::Proxy

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, ClassMethods
Includes:
Enumerable
Defined in:
lib/mongoid/association/referenced/has_many_through/proxy.rb

Overview

Read-only proxy for has_many :through associations. Wraps the lazy Criteria returned by the association and raises ReadonlyAssociation on any write attempt.

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

READONLY_METHODS =
i[
  << push concat substitute build new create create!
  delete delete_one delete_all destroy_all clear nullify
].freeze

Instance Method Summary collapse

Methods included from ClassMethods

eager_loader, embedded?

Constructor Details

#initialize(base, association, preloaded: nil) ⇒ Proxy

Returns a new instance of Proxy.



41
42
43
44
45
# File 'lib/mongoid/association/referenced/has_many_through/proxy.rb', line 41

def initialize(base, association, preloaded: nil)
  @_base        = base
  @_association = association
  @preloaded    = preloaded
end

Instance Method Details

#criteriaObject



47
48
49
# File 'lib/mongoid/association/referenced/has_many_through/proxy.rb', line 47

def criteria
  @criteria ||= @_association.criteria(@_base)
end