Class: Arxutils_Sqlite3::TransactStateGroup

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(*names) ⇒ TransactStateGroup

初期化



38
39
40
41
42
43
# File 'lib/arxutils_sqlite3/transactstate.rb', line 38

def initialize(*names)
  @names = names
  @state = :NONE
  @inst = {}
  names.map { |x| @inst[x] = TransactState.new }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, _lang = nil) ⇒ Object

指定名の状態を返す



68
69
70
# File 'lib/arxutils_sqlite3/transactstate.rb', line 68

def method_missing(name, _lang = nil)
  @inst[name]
end

Instance Method Details

#need?Boolean

処理の必要性の確認

Returns:

  • (Boolean)


46
47
48
# File 'lib/arxutils_sqlite3/transactstate.rb', line 46

def need?
  @state != :NONE
end

#resetObject

状態を:NONEに一括設定



62
63
64
65
# File 'lib/arxutils_sqlite3/transactstate.rb', line 62

def reset
  @state = :NONE
  set_all_inst_state
end

#respond_to_missing?(symbol) ⇒ Boolean

指定名に対応するかを返す

Returns:

  • (Boolean)


73
74
75
76
# File 'lib/arxutils_sqlite3/transactstate.rb', line 73

def respond_to_missing?(symbol)
  name = symbol.to_s
  @names.include?(name)
end

#set_all_inst_stateObject

状態の一括設定



51
52
53
# File 'lib/arxutils_sqlite3/transactstate.rb', line 51

def set_all_inst_state
  @inst.map { |x| x[1].state = @state }
end

#traceObject

状態を:TRACEに一括設定



56
57
58
59
# File 'lib/arxutils_sqlite3/transactstate.rb', line 56

def trace
  @state = :TRACE
  set_all_inst_state
end