Class: DoubleEntry::Account
- Inherits:
-
Object
- Object
- DoubleEntry::Account
- Defined in:
- lib/double_entry/account.rb
Defined Under Namespace
Classes: ActiveRecordScopeFactory, Instance, Set
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#positive_only ⇒ Object
Returns the value of attribute positive_only.
-
#scope_identifier ⇒ Object
Returns the value of attribute scope_identifier.
Class Method Summary collapse
- .account(defined_accounts, identifier, options = {}) ⇒ Object private
- .currency(defined_accounts, account) ⇒ Object private
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Account
constructor
A new instance of Account.
- #scoped? ⇒ Boolean
Constructor Details
#initialize(attributes) ⇒ Account
Returns a new instance of Account.
133 134 135 136 |
# File 'lib/double_entry/account.rb', line 133 def initialize(attributes) attributes.each { |name, value| send("#{name}=", value) } self.currency ||= Money.default_currency end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
131 132 133 |
# File 'lib/double_entry/account.rb', line 131 def currency @currency end |
#identifier ⇒ Object
Returns the value of attribute identifier.
131 132 133 |
# File 'lib/double_entry/account.rb', line 131 def identifier @identifier end |
#positive_only ⇒ Object
Returns the value of attribute positive_only.
131 132 133 |
# File 'lib/double_entry/account.rb', line 131 def positive_only @positive_only end |
#scope_identifier ⇒ Object
Returns the value of attribute scope_identifier.
131 132 133 |
# File 'lib/double_entry/account.rb', line 131 def scope_identifier @scope_identifier end |
Class Method Details
.account(defined_accounts, identifier, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 9 |
# File 'lib/double_entry/account.rb', line 6 def self.account(defined_accounts, identifier, = {}) account = defined_accounts.find(identifier, [:scope].present?) DoubleEntry::Account::Instance.new(:account => account, :scope => [:scope]) end |
.currency(defined_accounts, account) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 15 16 17 18 19 20 |
# File 'lib/double_entry/account.rb', line 12 def self.currency(defined_accounts, account) code = account.is_a?(Symbol) ? account : account.identifier found_account = defined_accounts.detect do |account| account.identifier == code end found_account.currency end |
Instance Method Details
#scoped? ⇒ Boolean
138 139 140 |
# File 'lib/double_entry/account.rb', line 138 def scoped? !!scope_identifier end |