Module: Istox::BlockchainReceiptQuery
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/istox/models/concerns/blockchain_receipt_query.rb
Instance Method Summary collapse
- #get_blockchain_receipts ⇒ Object
-
#handle_confirm(resource_action) ⇒ Object
overrideable, when blockchain transaction has confirmed.
-
#handle_extra ⇒ Object
overrideable, extra data that will be published back to frontend.
-
#handle_fail(resource_action) ⇒ Object
overrideable, when blockchain transaction has failed.
- #last_receipt ⇒ Object
-
#outcome ⇒ Object
outcome of the blockchain transaction, can be “pending” / “confirmed” / “failed”.
Instance Method Details
#get_blockchain_receipts ⇒ Object
36 37 38 |
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 36 def get_blockchain_receipts ::Istox::BlockchainReceipt.where(resource_id: self.id, resource_name: self.class.name).all end |
#handle_confirm(resource_action) ⇒ Object
overrideable, when blockchain transaction has confirmed
6 7 8 |
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 6 def handle_confirm(resource_action) self end |
#handle_extra ⇒ Object
overrideable, extra data that will be published back to frontend
16 17 18 |
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 16 def handle_extra nil end |
#handle_fail(resource_action) ⇒ Object
overrideable, when blockchain transaction has failed
11 12 13 |
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 11 def handle_fail(resource_action) self end |
#last_receipt ⇒ Object
40 41 42 |
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 40 def last_receipt ::Istox::BlockchainReceipt.where(resource_id: self.id, resource_name: self.class.name).last end |
#outcome ⇒ Object
outcome of the blockchain transaction, can be “pending” / “confirmed” / “failed”
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 21 def outcome blockchain_receipts = get_blockchain_receipts return "confirmed" if blockchain_receipts.empty? # return failed state if there is any failed hashes return "failed" if blockchain_receipts.any?{ |r| r.status == 'failed' } # return pending state if there is any pending hashes return "pending" if blockchain_receipts.any?{ |r| r.status == 'pending' } # return confirmed otherwise return "confirmed" end |