Class: Rollwire::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/rollwire/report.rb

Constant Summary collapse

EVENT_NAME =
"ignored_rollback.rollwire"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inner_location:, mode:, outer_location:, writes:) ⇒ Report

Returns a new instance of Report.



9
10
11
12
13
14
# File 'lib/rollwire/report.rb', line 9

def initialize(inner_location:, mode:, outer_location:, writes:)
  @inner_location = inner_location
  @mode = mode
  @outer_location = outer_location
  @writes = writes
end

Instance Attribute Details

#inner_locationObject (readonly)

Returns the value of attribute inner_location.



7
8
9
# File 'lib/rollwire/report.rb', line 7

def inner_location
  @inner_location
end

#modeObject (readonly)

Returns the value of attribute mode.



7
8
9
# File 'lib/rollwire/report.rb', line 7

def mode
  @mode
end

#outer_locationObject (readonly)

Returns the value of attribute outer_location.



7
8
9
# File 'lib/rollwire/report.rb', line 7

def outer_location
  @outer_location
end

#writesObject (readonly)

Returns the value of attribute writes.



7
8
9
# File 'lib/rollwire/report.rb', line 7

def writes
  @writes
end

Instance Method Details

#to_sObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rollwire/report.rb', line 16

def to_s
  <<~REPORT.chomp
    Rollwire::IgnoredNestedRollback

    ActiveRecord::Rollback was raised inside a transaction
    that joined an existing transaction.

    #{write_consequence}

    Inner transaction:
      #{inner_location || '(unknown)'}

    Outer transaction:
      #{outer_location || '(not captured)'}

    Use `requires_new: true` to roll back only the inner block,
    or propagate the failure to the outer transaction.
  REPORT
end