Class: DoubleEntry::Account
- Inherits:
-
Object
- Object
- DoubleEntry::Account
- Defined in:
- lib/double_entry/account.rb
Defined Under Namespace
Classes: ActiveRecordScopeFactory, Instance, Set
Class Attribute Summary collapse
- .accounts ⇒ Object private
Instance Attribute Summary collapse
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#positive_only ⇒ Object
readonly
Returns the value of attribute positive_only.
-
#scope_identifier ⇒ Object
readonly
Returns the value of attribute scope_identifier.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Account
constructor
A new instance of Account.
- #scoped? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Account
Returns a new instance of Account.
137 138 139 140 141 142 |
# File 'lib/double_entry/account.rb', line 137 def initialize(args) @identifier = args[:identifier] @scope_identifier = args[:scope_identifier] @positive_only = args[:positive_only] @currency = args[:currency] || Money.default_currency end |
Class Attribute Details
Instance Attribute Details
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
135 136 137 |
# File 'lib/double_entry/account.rb', line 135 def currency @currency end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
135 136 137 |
# File 'lib/double_entry/account.rb', line 135 def identifier @identifier end |
#positive_only ⇒ Object (readonly)
Returns the value of attribute positive_only.
135 136 137 |
# File 'lib/double_entry/account.rb', line 135 def positive_only @positive_only end |
#scope_identifier ⇒ Object (readonly)
Returns the value of attribute scope_identifier.
135 136 137 |
# File 'lib/double_entry/account.rb', line 135 def scope_identifier @scope_identifier end |
Class Method Details
.account(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.
14 15 16 17 |
# File 'lib/double_entry/account.rb', line 14 def account(identifier, = {}) account = accounts.find(identifier, [:scope].present?) Instance.new(:account => account, :scope => [:scope]) end |
.currency(identifier) ⇒ 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.
20 21 22 |
# File 'lib/double_entry/account.rb', line 20 def currency(identifier) accounts.detect { |a| a.identifier == identifier }.try(:currency) end |
Instance Method Details
#scoped? ⇒ Boolean
144 145 146 |
# File 'lib/double_entry/account.rb', line 144 def scoped? !!scope_identifier end |