Class: RailsBand::ActiveRecord::Event::Transaction

Inherits:
BaseEvent
  • Object
show all
Defined in:
lib/rails_band/active_record/event/transaction.rb

Overview

A wrapper for the event that is passed to transaction.active_record.

Instance Attribute Summary

Attributes inherited from BaseEvent

#allocations, #cpu_time, #duration, #end, #idle_time, #name, #time, #transaction_id

Instance Method Summary collapse

Methods inherited from BaseEvent

#initialize, #slice, #to_h

Constructor Details

This class inherits a constructor from RailsBand::BaseEvent

Instance Method Details

#connection ⇒ Object



18
19
20
# File 'lib/rails_band/active_record/event/transaction.rb', line 18

def connection
  @connection ||= @event.payload.fetch(:connection)
end

#outcome ⇒ Object



14
15
16
# File 'lib/rails_band/active_record/event/transaction.rb', line 14

def outcome
  @outcome ||= @event.payload.fetch(:outcome)
end

#transaction ⇒ Object

The :transaction key was added in Rails 7.2. It is absent on Rails 7.1, where this event is also emitted with only :connection and :outcome.



10
11
12
# File 'lib/rails_band/active_record/event/transaction.rb', line 10

def transaction
  @transaction ||= @event.payload[:transaction]
end