Class: ISO8583::MKB::ISO8583Transaction
- Inherits:
-
Object
- Object
- ISO8583::MKB::ISO8583Transaction
- Defined in:
- lib/iso8583-mkb/iso8583_transaction.rb
Constant Summary collapse
- @@trace_counter =
0
Instance Attribute Summary collapse
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
Instance Method Summary collapse
- #complete ⇒ Object
-
#initialize(gateway) ⇒ ISO8583Transaction
constructor
A new instance of ISO8583Transaction.
- #request {|message| ... } ⇒ Object
Constructor Details
#initialize(gateway) ⇒ ISO8583Transaction
Returns a new instance of ISO8583Transaction.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/iso8583-mkb/iso8583_transaction.rb', line 7 def initialize(gateway) @gateway = gateway now = Time.now @id = (now.year % 100) * 1_00_0000_0000 + (now.mday) * 1_0000_0000 + now.hour * 3600_000 + now.min * 60_000 + now.sec * 1_000 + now.usec / 1_000 @trace = @@trace_counter += 1 @started_at = now Logging.logger.debug "Transaction #{id} started" end |
Instance Attribute Details
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
3 4 5 |
# File 'lib/iso8583-mkb/iso8583_transaction.rb', line 3 def gateway @gateway end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/iso8583-mkb/iso8583_transaction.rb', line 3 def id @id end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
3 4 5 |
# File 'lib/iso8583-mkb/iso8583_transaction.rb', line 3 def trace @trace end |
Instance Method Details
#complete ⇒ Object
37 38 39 40 41 |
# File 'lib/iso8583-mkb/iso8583_transaction.rb', line 37 def complete # TODO: track transactions Logging.logger.debug "Transaction #{@id} completed" end |
#request {|message| ... } ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/iso8583-mkb/iso8583_transaction.rb', line 24 def request(&block) = MKBMessage.new ["Transmission Date and Time"] = @started_at ["Systems Trace Audit Number"] = @trace ["Time, Local Transaction"] = @started_at ["Date, Local Transaction"] = @started_at .reference = @id.to_s yield ISO8583Request.new self, end |