Module: MoneyAttribute::CurrencyCondition
- Included in:
- QueryMethods
- Defined in:
- lib/money_attribute/query/currency_condition.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#resolve_currency_condition(attr, currency) ⇒ ActiveRecord::Relation
Builds a currency filter for the registered money attribute.
Instance Method Details
#resolve_currency_condition(attr, currency) ⇒ ActiveRecord::Relation
Builds a currency filter for the registered money attribute.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/money_attribute/query/currency_condition.rb', line 12 def resolve_currency_condition(attr, currency) spec = money_attribute_spec!(attr) unless spec.composite? raise ArgumentError, "#{klass.name}.#{attr} is a money_amount attribute with no currency column" end code = currency.is_a?(Mint::Currency) ? currency.code : currency.to_s where(spec.currency_col => code) end |