Class: Petra::Components::Entries::AttributeChange

Inherits:
LogEntry
  • Object
show all
Defined in:
lib/petra/components/entries/attribute_change.rb

Instance Attribute Summary

Attributes inherited from LogEntry

#attribute, #object_class, #object_persisted, #persist_on_retry, #section, #transaction_persisted

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LogEntry

#<=>, #attribute_change?, #attribute_read?, #enqueue_for_persisting!, #for_object?, from_hash, #initialize, #kind?, #load_proxy, log!, #mark_as_object_persisted!, #mark_as_persisted!, #marked_for_destruction?, #object_initialization?, #object_persistence?, #persist?, #persist_on_retry?, #to_h, #to_s, #undo!

Methods included from Util::FieldAccessors

#[], #[]=, #fields, included

Methods included from Util::Registrable

included

Constructor Details

This class inherits a constructor from Petra::Components::LogEntry

Class Method Details

.kindObject



11
12
13
# File 'lib/petra/components/entries/attribute_change.rb', line 11

def self.kind
  :attribute_change
end

Instance Method Details

#apply!Object



15
16
17
18
19
20
21
22
23
# File 'lib/petra/components/entries/attribute_change.rb', line 15

def apply!
  # Check if there is an an attribute change veto which is newer than this
  # attribute change. If there is, we may not apply this entry.
  # TODO: Check if this behaviour is sufficient.
  return if transaction.attribute_change_veto?(load_proxy, attribute: attribute)

  # Otherwise, use the logged method to set the new attribute value
  proxied_object.send(method, new_value)
end