Sha256: 28b2b61d3934ca91b616bf3f57d9f74cc61cf32f41c105ceba9828e26f0e1a4c

Contents?: true

Size: 595 Bytes

Versions: 7

Compression:

Stored size: 595 Bytes

Contents

module TxCatcher

  class Deposit < Sequel::Model
    many_to_one :transaction
    many_to_one :address

    attr_accessor :address_string

    plugin :serialization, :json, :rbf_transaction_ids

    def before_save
      self.rbf_transaction_ids
    end

    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

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

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
txcatcher-0.2.14 lib/txcatcher/models/deposit.rb
txcatcher-0.2.12 lib/txcatcher/models/deposit.rb
txcatcher-0.2.11 lib/txcatcher/models/deposit.rb
txcatcher-0.2.10 lib/txcatcher/models/deposit.rb
txcatcher-0.2.9 lib/txcatcher/models/deposit.rb
txcatcher-0.2.8 lib/txcatcher/models/deposit.rb
txcatcher-0.2.6 lib/txcatcher/models/deposit.rb