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.



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

def initialize(active_record_class)
  @active_record_class = active_record_class
end

Instance Method Details

#scope_identifierObject



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

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