Class: TestData::SavePoint
- Inherits:
-
Object
- Object
- TestData::SavePoint
- Defined in:
- lib/test_data/save_point.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#transaction ⇒ Object
readonly
Returns the value of attribute transaction.
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#initialize(name) ⇒ SavePoint
constructor
A new instance of SavePoint.
- #rollback! ⇒ Object
Constructor Details
#initialize(name) ⇒ SavePoint
Returns a new instance of SavePoint.
5 6 7 8 |
# File 'lib/test_data/save_point.rb', line 5 def initialize(name) @name = name @transaction = connection.begin_transaction(joinable: false, _lazy: false) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/test_data/save_point.rb', line 3 def name @name end |
#transaction ⇒ Object (readonly)
Returns the value of attribute transaction.
3 4 5 |
# File 'lib/test_data/save_point.rb', line 3 def transaction @transaction end |
Instance Method Details
#active? ⇒ Boolean
10 11 12 |
# File 'lib/test_data/save_point.rb', line 10 def active? !@transaction.state.finalized? end |
#rollback! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/test_data/save_point.rb', line 14 def rollback! warn_if_not_rollbackable! while active? connection.rollback_transaction end end |