Sha256: 6a814628413273bed0dfb71798d05441fb28c755416d9f918ae00c5605442487
Contents?: true
Size: 758 Bytes
Versions: 55
Compression:
Stored size: 758 Bytes
Contents
# encoding: utf-8 module Mongoid module Relations module Builders module Referenced class One < Builder # This builder either takes an _id or an object and queries for the # inverse side using the id or sets the object. # # @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? return nil if base.new_record? metadata.criteria(Conversions.flag(object, metadata), base.class).first end end end end end end
Version data entries
55 entries across 50 versions & 3 rubygems