def build(klass, attributes = nil)
      attributes ||= {}
      type = attributes[TYPE] || attributes[TYPE.to_sym]
      if type && klass._types.include?(type)
        type.constantize.new(attributes)
      else
        klass.new(attributes)
      end
    end
def build(klass, attributes = nil)
      attributes ||= {}
      type = attributes[TYPE] || attributes[TYPE.to_sym]
      if type && klass._types.include?(type)
        type.constantize.new(attributes)
      else
        klass.new(attributes)
      end
    end
Builds a new +Document+ from the supplied attributes.

 @example Build the document.
   Mongoid::Factory.build(Person, { "name" => "Durran" })

 @param [ Class ] klass The class to instantiate from if _type is not present.
 @param [ Hash ] attributes The document attributes.

 @return [ Document ] The instantiated document.