lib/dm-transactions.rb
def commit
      if block_given?
        unless none?
          raise "Illegal state for commit with block: #{state}"
        end

        begin
          self.begin
          rval = within { |*block_args| yield(*block_args) }
        rescue Exception => exception
          if begin?
            rollback
          end
          raise exception
        ensure
          unless exception
            if begin?
              commit
            end
            return rval
          end
        end
      else
        unless begin?
          raise "Illegal state for commit without block: #{state}"
        end
        each_adapter(:commit_adapter, [:log_fatal_transaction_breakage])
        each_adapter(:close_adapter, [:log_fatal_transaction_breakage])
        self.state = :commit
      end
    end
def commit
      if block_given?
        unless none?
          raise "Illegal state for commit with block: #{state}"
        end

        begin
          self.begin
          rval = within { |*block_args| yield(*block_args) }
        rescue Exception => exception
          if begin?
            rollback
          end
          raise exception
        ensure
          unless exception
            if begin?
              commit
            end
            return rval
          end
        end
      else
        unless begin?
          raise "Illegal state for commit without block: #{state}"
        end
        each_adapter(:commit_adapter, [:log_fatal_transaction_breakage])
        each_adapter(:close_adapter, [:log_fatal_transaction_breakage])
        self.state = :commit
      end
    end
Commit the transaction

   If no block is given, it will simply commit any changes made since the
   Transaction did #begin.

 @param block<Block>   a block (taking the one argument, the Transaction) to
   execute within this transaction. The transaction will begin and commit
   around the block, and roll back if an exception is raised.

 @api private