Sha256: 78b2d24092d5b9200b0fef69bf1e1ff0f427edf6201b838c35573d14dc378dd4

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

module DataMapper
  module NestedAttributes
    
    module TransactionalSave
      
      ##
      # Overrides @see DataMapper::Resource#save to perform inside a transaction.
      # The current implementation simply wraps the saving of the complete object tree
      # inside a transaction and rolls back in case any exceptions are raised,
      # or any of the calls to
      #
      # @see DataMapper::Resource#save
      #
      # @return [true, false]
      #   true if all related resources were saved properly
      #
      def save(*)
        saved = false
        transaction { |t| t.rollback unless saved = super }
        saved
      end
      
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snusnu-dm-accepts_nested_attributes-0.11.0 lib/dm-accepts_nested_attributes/transactional_save.rb