Sha256: d888045ae818ca21c6cd1ae629302c42336f551640e26fdeaf9b88340e79baa7

Contents?: true

Size: 411 Bytes

Versions: 4

Compression:

Stored size: 411 Bytes

Contents

# frozen_string_literal: true

begin
  require "active_record"
rescue LoadError
end

module Solid
  class Process
    private

    if defined?(::ActiveRecord)
      def rollback_on_failure(model: ::ActiveRecord::Base)
        result = nil

        model.transaction do
          result = yield

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

        result
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solid-process-0.4.0 lib/solid/process/active_record.rb
solid-process-0.3.0 lib/solid/process/active_record.rb
solid-process-0.2.0 lib/solid/process/active_record.rb
solid-process-0.1.0 lib/solid/process/active_record.rb