Sha256: e236df74e8d4457e53cb2cbe2c888ab50164cd3cb5027f7e6362762d9ad4b892

Contents?: true

Size: 788 Bytes

Versions: 170

Compression:

Stored size: 788 Bytes

Contents

# encoding: utf-8
module Mongoid # :nodoc:
  module Relations #:nodoc:
    module Builders #:nodoc:
      module Referenced #:nodoc:
        class In < Builder

          # This builder either takes a foreign key and queries for the
          # object or a document, where it will just return it.
          #
          # @example Build the document.
          #   Builder.new(meta, attrs).build
          #
          # @param [ String ] type The type of document to query for.
          #
          # @return [ Document ] A single document.
          def build(type = nil)
            return object unless query?
            model = type ? type.constantize : metadata.klass
            metadata.criteria(object, model).from_map_or_db
          end
        end
      end
    end
  end
end

Version data entries

170 entries across 78 versions & 4 rubygems

Version Path
classiccms-0.5.16 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/relations/builders/referenced/in.rb
mongoid-2.5.0 lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/relations/builders/referenced/in.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/relations/builders/referenced/in.rb