Class: NWRFC::Transaction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handle) ⇒ Transaction

Returns a new instance of Transaction.



129
130
131
132
133
134
# File 'lib/nwrfc.rb', line 129

def initialize(handle)
  @handle = handle
  @error =  NWRFCLib::RFCError.new
  @submitted = false
  @confirmed = false
end

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



127
128
129
# File 'lib/nwrfc.rb', line 127

def handle
  @handle
end

Instance Method Details

#closeObject Also known as: destroy



150
151
152
153
154
155
# File 'lib/nwrfc.rb', line 150

def close
  return unless @handle
  rc = NWRFCLib.destroy_transaction(@handle, @error)
  NWRFC.check_error(@error) if rc > 0
  @handle = nil
end

#commitObject Also known as: submit



136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/nwrfc.rb', line 136

def commit
  unless @submitted
    rc = NWRFCLib.submit_transaction(@handle, @error)
    NWRFC.check_error(@error) if rc > 0
    @submitted = true
  end
  unless @confirmed
    rc = NWRFCLib.confirm_transaction(@handle, @error)
    NWRFC.check_error(@error) if rc > 0
    @confirmed = true
  end
  close
end