Class: Transactio::TransactionLogEntry

Inherits:
ApplicationRecord show all
Defined in:
lib/transactio/models/transaction_log_entry.rb

Instance Method Summary collapse

Instance Method Details

#object_change(attribute) ⇒ Object



26
27
28
29
30
# File 'lib/transactio/models/transaction_log_entry.rb', line 26

def object_change(attribute)
  return nil if object_change_from(attribute) == object_change_to(attribute)

  object_changes[attribute.to_s]
end

#object_change?(attribute) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/transactio/models/transaction_log_entry.rb', line 20

def object_change?(attribute)
  return false if object_change_from(attribute) == object_change_to(attribute)

  object_changes.key?(attribute.to_s)
end

#object_change_from(attribute) ⇒ Object



32
33
34
35
36
# File 'lib/transactio/models/transaction_log_entry.rb', line 32

def object_change_from(attribute)
  return nil if object_changes.nil?

  object_changes[attribute.to_s]&.first
end

#object_change_to(attribute) ⇒ Object



38
39
40
41
42
# File 'lib/transactio/models/transaction_log_entry.rb', line 38

def object_change_to(attribute)
  return nil if object_changes.nil?

  object_changes[attribute.to_s]&.last
end