3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/istox/helpers/blockchain_receipt_service.rb', line 3
def create!(blockchain_receipt_klass, txids, model, sid, action)
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
[txids].flatten.each do |txid|
blockchain_receipt = klass.new(
sid: sid,
txid: txid,
resource_name: model.class.name,
resource_id: model.id,
resource_action: action
)
blockchain_receipt.save!
end
end
|