12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/istox/helpers/blockchain_receipt_service.rb', line 12
def create!(tx_message, model, sid, action)
raise "Have you forgetten to init blockchain receipt service?" if ::Istox::BlockchainReceiptService.get_blockchain_receipt_klass == nil
blockchain_receipt_klass = ::Istox::BlockchainReceiptService.get_blockchain_receipt_klass
klass = class_eval("::#{blockchain_receipt_klass.name}")
unless klass <= ::Istox::BlockchainReceipt
raise RuntimeError, "#{blockchain_receipt_klass.name} does not inherit istox blockchain receipt"
end
klass.where(resource_name: model.class.name,
resource_id: model.id).destroy_all
(0...tx_message.txnCount).each do |i|
blockchain_receipt = klass.new(
sid: sid,
txid: tx_message.uuid,
resource_name: model.class.name,
resource_id: model.id,
resource_action: action
)
blockchain_receipt.save!
end
end
|