Class: ActsAsCalculator::CastVariableAttributes
- Inherits:
-
Object
- Object
- ActsAsCalculator::CastVariableAttributes
- Defined in:
- lib/acts_as_calculator/cast_variable_attributes.rb
Overview
Both authoring paths hand over the same loose variable declaration — an import file's
variables list and the API's — and both have to land on the same row, with the same
defaults. Keeping the defaulting here is what stops the two from drifting.
Class Method Summary collapse
Class Method Details
.call(variable) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/acts_as_calculator/cast_variable_attributes.rb', line 8 def self.call(variable) variable = variable.to_h.transform_keys(&:to_s) { name: variable["name"].to_s, source_type: (variable["source_type"] || "context").to_s, source_config: CastJsonSafe.(variable["source_config"] || {}), required: variable.fetch("required", true) != false } end |