Class: Bricolage::Parameters::DefaultValuesHandler
- Inherits:
-
Object
- Object
- Bricolage::Parameters::DefaultValuesHandler
- Defined in:
- lib/bricolage/parameters.rb
Overview
Handles default values given by variable.yml (global or subsystem variables) Declarations + values -> IntermediateValues
Instance Method Summary collapse
-
#initialize(decls) ⇒ DefaultValuesHandler
constructor
A new instance of DefaultValuesHandler.
- #parse(values) ⇒ Object
Constructor Details
#initialize(decls) ⇒ DefaultValuesHandler
Returns a new instance of DefaultValuesHandler.
60 61 62 |
# File 'lib/bricolage/parameters.rb', line 60 def initialize(decls) @decls = decls end |
Instance Method Details
#parse(values) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/bricolage/parameters.rb', line 64 def parse(values) unless values.kind_of?(Hash) raise ParameterError, "invalid type for 'defaults' global variable: #{values.class}" end parsed_values = {} values.each do |name, value| decl = @decls[name] next unless decl # ignore undeclared option val = decl.parse_value(value) # nil means really nil for default values. parsed_values[name] = val end IntermediateValues.new(@decls, parsed_values, Variables.new) end |