Class: TestData::SavePoint

Inherits:
Object
  • Object
show all
Defined in:
lib/test_data/save_point.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/test_data/save_point.rb', line 3

def name
  @name
end

#transactionObject (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

Returns:

  • (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