Sha256: 05bba37db2ed1e65ebacbbd113615bb314e9f0b9e2a50fe3d18cc45892ec0016

Contents?: true

Size: 810 Bytes

Versions: 2

Compression:

Stored size: 810 Bytes

Contents

module Arxutils
  class TransactState
    attr_accessor :ids , :state
    
    def initialize
      @ids = []
      @state = :NONE
    end

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

    def clear
      @ids = []
    end

    def need?
      @ids.size > 0
    end

  end

  class TransactStateGroup
    def initialize( *names )
      @state = :NONE
      @inst = {}
      names.map{|x| @inst[x] = TransactState.new }
    end
    
    def need?
      @state != :NONE
    end
    
    def set_all_inst_state
      @inst.map{|x| x[1].state = @state }
    end
    
    def trace
      @state = :TRACE
      set_all_inst_state
    end
    
    def reset
      @state = :NONE
      set_all_inst_state
    end
    
    def method_missing(name , lang = nil)
      @inst[name] 
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arxutils-0.1.36 lib/arxutils/transactstate.rb
arxutils-0.1.35 lib/arxutils/transactstate.rb