Module: MoneyAttribute::QueryHelpers
- Included in:
- QueryMethods
- Defined in:
- lib/money_attribute/query/helpers.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#extract_pick_value(row, spec, cursor) ⇒ Array(Object, Integer)
Extracts a single value from a flat row at the given cursor position.
-
#money_attribute_spec!(attr) ⇒ AttributeSpec
Returns the registered money attribute spec or raises when missing.
Instance Method Details
#extract_pick_value(row, spec, cursor) ⇒ Array(Object, Integer)
Extracts a single value from a flat row at the given cursor position.
24 25 26 27 28 |
# File 'lib/money_attribute/query/helpers.rb', line 24 def extract_pick_value(row, spec, cursor) return [row[cursor], cursor + 1] if spec.single? [spec.build_money(row[cursor], row[cursor + 1]), cursor + 2] end |
#money_attribute_spec!(attr) ⇒ AttributeSpec
Returns the registered money attribute spec or raises when missing.
11 12 13 14 15 16 |
# File 'lib/money_attribute/query/helpers.rb', line 11 def money_attribute_spec!(attr) spec = klass.money_attribute_spec(attr) raise ArgumentError, "#{attr} is not a money attribute on #{klass.name}" unless spec spec end |