Sha256: d2b5f279cff95ee4ee019c47cc84a1b1872a88ff205468b6f85ecff1d1630598

Contents?: true

Size: 277 Bytes

Versions: 2

Compression:

Stored size: 277 Bytes

Contents

# frozen_string_literal: true

module Solid::Result::RollbackOnFailure
  def rollback_on_failure(model: ::ActiveRecord::Base)
    result = nil

    model.transaction do
      result = yield

      raise ::ActiveRecord::Rollback if result.failure?
    end

    result
  end
end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
solid-result-2.0.0 examples/multiple_listeners/lib/solid/result/rollback_on_failure.rb
solid-result-2.0.0 examples/single_listener/lib/solid/result/rollback_on_failure.rb