Module: MoneyAttribute::AmountCondition

Included in:
QueryMethods
Defined in:
lib/money_attribute/query/amount_condition.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#resolve_amount_condition(attr, value) ⇒ ActiveRecord::Relation

Builds an amount filter for the registered money attribute.

Parameters:

  • attr (Symbol)

    the money attribute name

  • value (Mint::Money, Numeric, Range, Array)

    the filter value

Returns:

  • (ActiveRecord::Relation)

Raises:

  • (ArgumentError)

    if the attribute is not a registered money attribute



12
13
14
15
16
17
# File 'lib/money_attribute/query/amount_condition.rb', line 12

def resolve_amount_condition(attr, value)
  spec = money_attribute_spec!(attr)
  col = arel_table[spec.amount_col]

  where(build_amount_predicate(col, spec, value))
end