Sha256: d8e718d5ddf9021a1e64ce83ccbf47f545eb3b0ce3bdc188aff9e9fd949eb50f
Contents?: true
Size: 499 Bytes
Versions: 14
Compression:
Stored size: 499 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, attrs) type = attrs["_type"] type ? type.constantize.instantiate(attrs) : klass.instantiate(attrs) end end end
Version data entries
14 entries across 14 versions & 2 rubygems