Class: DoubleEntry::Account::ActiveRecordScopeFactory

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

Instance Method Summary collapse

Constructor Details

#initialize(active_record_class) ⇒ ActiveRecordScopeFactory

Returns a new instance of ActiveRecordScopeFactory.



62
63
64
# File 'lib/double_entry/account.rb', line 62

def initialize(active_record_class)
  @active_record_class = active_record_class
end

Instance Method Details

#scope_identifierObject



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/double_entry/account.rb', line 66

def scope_identifier
  lambda do |value|
    case value
    when @active_record_class
      value.id
    when String, Fixnum
      value
    else
      fail AccountScopeMismatchError, "Expected instance of `#{@active_record_class}`, received instance of `#{value.class}`"
    end
  end
end