Sha256: f5c374361cefeae6d9f81bb6bf2c9b2dfe2b42abed9aa3ef67f23d8aec4b8d70

Contents?: true

Size: 753 Bytes

Versions: 14

Compression:

Stored size: 753 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Association
    module Referenced
      class BelongsTo

        # Eager class for belongs_to associations.
        class Eager < Association::Referenced::Eager::Base

          private

          def preload
            raise Errors::EagerLoad.new(@association.name) if @association.polymorphic?

            @docs.each do |d|
              set_relation(d, nil)
            end

            each_loaded_document do |doc|
              id = doc.send(key)
              set_on_parent(id, doc)
            end
          end

          def group_by_key
            @association.foreign_key
          end

          def key
            @association.primary_key
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mongoid-7.0.13 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.12 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.11 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.10 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.8 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.7 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.6 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.5 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.4 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.3 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.2 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.1 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.0 lib/mongoid/association/referenced/belongs_to/eager.rb
mongoid-7.0.0.beta lib/mongoid/association/referenced/belongs_to/eager.rb