Class: Decent::UpdateHodling

Inherits:
Object
  • Object
show all
Defined in:
lib/decent/command/hodling/update_hodling.rb

Class Method Summary collapse

Class Method Details

.execute(args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/decent/command/hodling/update_hodling.rb', line 3

def self.execute(args)
  hodlings = Database[:holdings]
  hodlings.each do |hodling|
    currency = hodling[:currency]
    address  = hodling[:address]
    id       = hodling[:id]
    balance  = API.currency[currency].get_balance address

    if (hodlings.where(id: id).update(balance: balance, updated_at: DateTime.now))
      StoreHodling.store hodling
    end
  end
end