Class: Beaconable::ObjectWas

Inherits:
Object
  • Object
show all
Defined in:
lib/beaconable/object_was.rb

Overview

Captures the database state of an ActiveRecord object before changes. Used to track what changed during a save/transaction.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ ObjectWas

Returns a new instance of ObjectWas.



9
10
11
# File 'lib/beaconable/object_was.rb', line 9

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



7
8
9
# File 'lib/beaconable/object_was.rb', line 7

def object
  @object
end

Instance Method Details

#callObject

Captures the current database state and returns an immutable snapshot. For new records, returns a snapshot with nil values for all columns.



15
16
17
# File 'lib/beaconable/object_was.rb', line 15

def call
  AttributeSnapshot.new(build_attributes)
end