Class: Humanoid::Factory
Overview
:nodoc:
Class Method Summary collapse
-
.build(klass, attrs) ⇒ Object
Builds a new
Document
from the supplied attributes.
Class Method Details
.build(klass, attrs) ⇒ Object
Builds a new Document
from the supplied attributes.
Example:
Humanoid::Factory.build(Person, {})
Options:
klass: The class to instantiate from if _type is not present. attributes: The Document
attributes.
14 15 16 17 |
# File 'lib/humanoid/factory.rb', line 14 def self.build(klass, attrs) type = attrs["_type"] type ? type.constantize.instantiate(attrs) : klass.instantiate(attrs) end |