Class: DoubleEntry::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/double_entry/account.rb

Defined Under Namespace

Classes: ActiveRecordScopeFactory, Instance, Set

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

.accountsObject

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.



9
10
11
# File 'lib/double_entry/account.rb', line 9

def accounts
  @accounts ||= Set.new
end

Instance Attribute Details

#currencyObject (readonly)

Returns the value of attribute currency.



135
136
137
# File 'lib/double_entry/account.rb', line 135

def currency
  @currency
end

#identifierObject (readonly)

Returns the value of attribute identifier.



135
136
137
# File 'lib/double_entry/account.rb', line 135

def identifier
  @identifier
end

#positive_onlyObject (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_identifierObject (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 (identifier, options = {})
   = accounts.find(identifier, options[:scope].present?)
  Instance.new(:account => , :scope => options[: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

Returns:

  • (Boolean)


144
145
146
# File 'lib/double_entry/account.rb', line 144

def scoped?
  !!scope_identifier
end