Class: Transactionable::BankAccount

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/transactionable/bank_account.rb

Instance Method Summary collapse

Instance Method Details

#amount_in_cents(amount) ⇒ Object



31
32
33
# File 'app/models/transactionable/bank_account.rb', line 31

def amount_in_cents(amount)
  (amount * 100).to_i
end

#credit!(amount) ⇒ Object



25
26
27
28
29
# File 'app/models/transactionable/bank_account.rb', line 25

def credit!(amount)
  remote_credit = remote.credit(amount: amount_in_cents(amount))
  transaction = Credit.create_from_remote(remote_credit)
  credits << transaction
end

#remoteObject



9
10
11
12
13
# File 'app/models/transactionable/bank_account.rb', line 9

def remote
  if  && .synced?
    .fetch
  end
end

#syncObject



15
16
17
18
19
20
21
22
23
# File 'app/models/transactionable/bank_account.rb', line 15

def sync
   = remote
  self.bank_name = .bank_name
  self.description = .
  self.name = .name
  self.can_debit = .can_debit
  self. = .type
  save
end