Class: ActsAsCalculator::ResolveVariables
- Inherits:
-
Object
- Object
- ActsAsCalculator::ResolveVariables
- Defined in:
- lib/acts_as_calculator/resolve_variables.rb
Constant Summary collapse
- SOURCE_TYPES =
%i[attribute method lookup context].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(specs:, calculable: nil, context: {}, lookups: {}) ⇒ ResolveVariables
constructor
A new instance of ResolveVariables.
Constructor Details
#initialize(specs:, calculable: nil, context: {}, lookups: {}) ⇒ ResolveVariables
Returns a new instance of ResolveVariables.
11 12 13 14 15 16 |
# File 'lib/acts_as_calculator/resolve_variables.rb', line 11 def initialize(specs:, calculable: nil, context: {}, lookups: {}) @specs = specs @calculable = calculable @context = context @lookups = lookups end |
Class Method Details
.call ⇒ Object
7 8 9 |
# File 'lib/acts_as_calculator/resolve_variables.rb', line 7 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 |
# File 'lib/acts_as_calculator/resolve_variables.rb', line 18 def call variables.each_with_object({}) do |spec, inputs| inputs[spec.name] = resolve(spec) end end |