Sha256: 97b92b86e7645d7455147cb2cc4a29e1afd480fa09f7ba26f832813ad442852d
Contents?: true
Size: 539 Bytes
Versions: 33
Compression:
Stored size: 539 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: class Factory #:nodoc: # Builds a new +Document+ from the supplied attributes. # # Example: # # <tt>Mongoid::Factory.build(Person, {})</tt> # # Options: # # klass: The class to instantiate from if _type is not present. # attributes: The +Document+ attributes. def self.build(klass, attributes) attrs = {}.merge(attributes) type = attrs["_type"] type ? type.constantize.instantiate(attrs) : klass.instantiate(attrs) end end end
Version data entries
33 entries across 33 versions & 7 rubygems