envato/double_entry — pull request #70 by orien (2014-11-12 08:41:33+00:00)
Title: Balance bug fix

Fix #59. `DoubleEntry::balance` now raises a `DoubleEntry::AccountScopeMismatchError` if the scope provided is not of the same type in the account definition.

Eg:

```ruby
DoubleEntry.configure do |config|
config.define_accounts do |accounts|
user_scope = accounts.active_record_scope_identifier(User)
accounts.define(identifier: :cash, scope_identifier: user_scope)
end

DoubleEntry.account(:cash, scope: User.new(id: 1)).balance #=> Money.zero
DoubleEntry.balance(:cash, scope: User.new(id: 1)) #=> Money.zero

DoubleEntry.account(:cash, scope: Bank.new(id: 1)) #=> raise DoubleEntry::AccountScopeMismatchError
DoubleEntry.balance(:cash, scope: Bank.new(id: 1)) #=> raise DoubleEntry::AccountScopeMismatchError
```