Sha256: ed46d0bb4dfb8d5e0145d2d744b8b642e6bcc73c34d063c30cfc96d9fe8fbf0a
Contents?: true
Size: 813 Bytes
Versions: 18
Compression:
Stored size: 813 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 IdentityMap.get(model, object) || metadata.criteria(object, model).first end end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems