Class: DoubleEntry::AccountBalance
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- DoubleEntry::AccountBalance
- Extended by:
- EncapsulateAsMoney
- Defined in:
- lib/double_entry/account_balance.rb
Overview
Account balance records cache the current balance for each account. They also provide a database representation of an account that we can use to do DB level locking.
See DoubleEntry::Locking for more info on locking.
Account balances are created on demand when transfers occur.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_by_account(account, options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/double_entry/account_balance.rb', line 22 def self.find_by_account(account, = {}) scope = where(:scope => account.scope_identity, :account => account.identifier.to_s) scope = scope.lock(true) if [:lock] scope.first end |
Instance Method Details
#account=(account) ⇒ Object
16 17 18 19 20 |
# File 'lib/double_entry/account_balance.rb', line 16 def account=(account) self[:account] = account.identifier.to_s self[:scope] = account.scope_identity account end |