lib/dynamoid/document.rb in dynamoid-0.3.0 vs lib/dynamoid/document.rb in dynamoid-0.3.1

- old
+ new

@@ -19,40 +19,32 @@ # # @return [Dynamoid::Document] the saved document # # @since 0.2.0 def create(attrs = {}) - obj = self.new(attrs) - obj.run_callbacks(:create) do - obj.save - end - obj + new(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 = {}) - obj = self.new(attrs) - obj.run_callbacks(:create) do - obj.save! - end - obj + new(attrs).tap(&:save!) end # Initialize a new object. # # @param [Hash] attrs Attributes with which to create the object. # # @return [Dynamoid::Document] the new document # # @since 0.2.0 def build(attrs = {}) - self.new(attrs) + new(attrs) end # Does this object exist? # # @param [String] id the id of the object