lib/mongoid/factory.rb in mongoid-1.9.5 vs lib/mongoid/factory.rb in mongoid-2.0.0.alpha

- old
+ new

@@ -9,11 +9,10 @@ # # Options: # # klass: The class to instantiate from if _type is not present. # attributes: The +Document+ attributes. - def self.build(klass, attributes) - attrs = {}.merge(attributes) + def self.build(klass, attrs) type = attrs["_type"] type ? type.constantize.instantiate(attrs) : klass.instantiate(attrs) end end end