Class: Transactionable::BankAccount

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

Constant Summary collapse

TYPES =
["checking", "savings"]

Instance Method Summary collapse

Instance Method Details

#amount_in_cents(amount) ⇒ Object



33
34
35
# File 'app/models/transactionable/bank_account.rb', line 33

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

#credit!(amount) ⇒ Object



27
28
29
30
31
# File 'app/models/transactionable/bank_account.rb', line 27

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

#remoteObject



11
12
13
14
15
# File 'app/models/transactionable/bank_account.rb', line 11

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

#syncObject



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

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