Class: Arxutils_Sqlite3::TransactState

Inherits:
Object
  • Object
show all
Defined in:
lib/arxutils_sqlite3/transactstate.rb

Overview

簡易的なトランザクション処理

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTransactState

初期化



12
13
14
15
16
17
# File 'lib/arxutils_sqlite3/transactstate.rb', line 12

def initialize
  # 対象ID群
  @ids = []
  # 状態
  @state = :NONE
end

Instance Attribute Details

#idsObject (readonly)

対象ID群



7
8
9
# File 'lib/arxutils_sqlite3/transactstate.rb', line 7

def ids
  @ids
end

#stateObject

状態



9
10
11
# File 'lib/arxutils_sqlite3/transactstate.rb', line 9

def state
  @state
end

Instance Method Details

#add(xid) ⇒ Object

:TRACE状態の時のみ対象IDとして追加



20
21
22
# File 'lib/arxutils_sqlite3/transactstate.rb', line 20

def add(xid)
  @ids << xid if @state == :TRACE
end

#clearObject

対象ID群をクリア



25
26
27
# File 'lib/arxutils_sqlite3/transactstate.rb', line 25

def clear
  @ids = []
end

#need?Boolean

処理の必要性の確認

Returns:

  • (Boolean)


30
31
32
# File 'lib/arxutils_sqlite3/transactstate.rb', line 30

def need?
  @ids.size.positive?
end