Class: Beaconable::ObjectWas
- Inherits:
-
Object
- Object
- Beaconable::ObjectWas
- 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
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#call ⇒ Object
Captures the current database state and returns an immutable snapshot.
-
#initialize(object) ⇒ ObjectWas
constructor
A new instance of ObjectWas.
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
#object ⇒ Object (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
#call ⇒ Object
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 |