Sha256: f07142dfc54dd435b9b74356daf495dff583ce8fa58880201a4db753fe691d9e
Contents?: true
Size: 780 Bytes
Versions: 2
Compression:
Stored size: 780 Bytes
Contents
# encoding: utf-8 module Mongoid # :nodoc: module Relations #:nodoc: module Builders #:nodoc: module Referenced #:nodoc: 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? metadata.klass.first( :conditions => { metadata.foreign_key => object } ) end end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
mongoid-braxton-2.0.2 | lib/mongoid/relations/builders/referenced/one.rb |
mongoid-2.0.2 | lib/mongoid/relations/builders/referenced/one.rb |