Class: Zold::Check
- Inherits:
-
Object
- Object
- Zold::Check
- Defined in:
- lib/zold/commands/check.rb
Overview
Wallet checking command
Instance Method Summary collapse
-
#initialize(wallet:, wallets:, log: Log::Quiet.new) ⇒ Check
constructor
A new instance of Check.
- #run ⇒ Object
Constructor Details
Instance Method Details
#run ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/zold/commands/check.rb', line 38 def run @wallet.income do |t| bnf = Pull.new( wallet: @wallets.find(Id.new(t[:beneficiary])), log: @log ).run bnf.check(t[:id], t[:amount], @wallet.id) end balance = @wallet.balance if balance.negative? && !@wallet.root? raise "Negative balance of #{@wallet} is not allowed: #{balance}" end @log.info("The #{@wallet} is clean") true end |