Class: CassandraObject::Savepoints::Rollback
- Inherits:
-
Object
- Object
- CassandraObject::Savepoints::Rollback
- Defined in:
- lib/cassandra_object/savepoints.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#record ⇒ Object
Returns the value of attribute record.
-
#rollback_attributes ⇒ Object
Returns the value of attribute rollback_attributes.
Instance Method Summary collapse
-
#initialize(action, record) ⇒ Rollback
constructor
A new instance of Rollback.
- #run! ⇒ Object
Constructor Details
#initialize(action, record) ⇒ Rollback
Returns a new instance of Rollback.
5 6 7 8 9 10 11 12 13 |
# File 'lib/cassandra_object/savepoints.rb', line 5 def initialize(action, record) @action = action @record = record if action == :update @rollback_attributes = record.changed_attributes.deep_dup elsif action == :create @rollback_attributes = record.attributes.deep_dup end end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
4 5 6 |
# File 'lib/cassandra_object/savepoints.rb', line 4 def action @action end |
#record ⇒ Object
Returns the value of attribute record.
4 5 6 |
# File 'lib/cassandra_object/savepoints.rb', line 4 def record @record end |
#rollback_attributes ⇒ Object
Returns the value of attribute rollback_attributes.
4 5 6 |
# File 'lib/cassandra_object/savepoints.rb', line 4 def rollback_attributes @rollback_attributes end |
Instance Method Details
#run! ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/cassandra_object/savepoints.rb', line 15 def run! case action when :destroy record.class.remove(record.id) when :create, :update record.class.write(record.id, rollback_attributes) end end |