Module: MoneyAttribute::PluckAmount Private
- Included in:
- QueryMethods
- Defined in:
- lib/money_attribute/query/pluck.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Internal pluck resolution for the pluck_amount query helper.
Instance Method Summary collapse
-
#pluck_amount(*attrs) ⇒ Array<Mint::Money>, Array<Array>
private
Plucks money-aware amounts for one or more attributes.
Instance Method Details
#pluck_amount(*attrs) ⇒ Array<Mint::Money>, Array<Array>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Plucks money-aware amounts for one or more attributes.
15 16 17 18 19 20 21 22 23 |
# File 'lib/money_attribute/query/pluck.rb', line 15 def pluck_amount(*attrs) raise ArgumentError, 'No attribute specified' if attrs.empty? specs = attrs.map { |attr| money_attribute_spec!(attr) } return pluck_single_amount(specs.first) if specs.length == 1 raw = pluck(*specs.flat_map(&:columns)) raw.map { |row| extract_money_row(row, specs) } end |