lib/dynamoid/document.rb in dynamoid-edge-1.1.1 vs lib/dynamoid/document.rb in dynamoid-edge-1.1.2
- old
+ new
@@ -70,21 +70,21 @@
#
# @return [Dynamoid::Document] the saved document
#
# @since 0.2.0
def create(attrs = {})
- attrs[:type] ? attrs[:type].constantize.new(attrs).tap(&:save) : new(attrs).tap(&:save)
+ build(attrs).tap(&:save)
end
# Initialize a new object and immediately save it to the database. Raise an exception if persistence failed.
#
# @param [Hash] attrs Attributes with which to create the object.
#
# @return [Dynamoid::Document] the saved document
#
# @since 0.2.0
def create!(attrs = {})
- attrs[:type] ? attrs[:type].constantize.new(attrs).tap(&:save!) : new(attrs).tap(&:save!)
+ build(attrs).tap(&:save!)
end
# Initialize a new object.
#
# @param [Hash] attrs Attributes with which to create the object.