Class: Smith::Workflow::Composite::BudgetMath

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/smith/workflow/composite/budget_math.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.sum(consumptions) ⇒ Object



19
# File 'lib/smith/workflow/composite/budget_math.rb', line 19

def self.sum(consumptions) = new(consumptions).sum

Instance Method Details

#sumObject



21
22
23
24
25
26
27
28
# File 'lib/smith/workflow/composite/budget_math.rb', line 21

def sum
  Budget::DecimalContext.call do
    totals = {}
    integer_dimensions = {}
    consumptions.each { accumulate!(_1, totals, integer_dimensions) }
    externalize(totals, integer_dimensions)
  end
end