Class: TxCatcher::Deposit

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/txcatcher/models/deposit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#address_stringObject

Returns the value of attribute address_string.



7
8
9
# File 'lib/txcatcher/models/deposit.rb', line 7

def address_string
  @address_string
end

Instance Method Details

#amount_in_btcObject



17
18
19
# File 'lib/txcatcher/models/deposit.rb', line 17

def amount_in_btc
  CryptoUnit.new(Config["currency"], self.amount, from_unit: :primary).to_standart
end

#before_saveObject



9
10
11
12
13
14
15
# File 'lib/txcatcher/models/deposit.rb', line 9

def before_save
  if @address_string
    self.address = Address.find_or_create(address: @address_string)
  end

  self.address.update(received: self.address.received + self.amount)
end