Class: Bricolage::Parameters::IntermediateValues
- Inherits:
-
Object
- Object
- Bricolage::Parameters::IntermediateValues
- Defined in:
- lib/bricolage/parameters.rb
Overview
Unified intermediate param values representation. This class is used for both of *.job file and options.
Instance Attribute Summary collapse
-
#decls ⇒ Object
readonly
Returns the value of attribute decls.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#initialize(decls, values, vars) ⇒ IntermediateValues
constructor
A new instance of IntermediateValues.
- #keys ⇒ Object
- #resolve(ctx, vars) ⇒ Object
- #update(other) ⇒ Object
Constructor Details
#initialize(decls, values, vars) ⇒ IntermediateValues
Returns a new instance of IntermediateValues.
147 148 149 150 151 |
# File 'lib/bricolage/parameters.rb', line 147 def initialize(decls, values, vars) @decls = decls # Declarations @values = values # {name => a} @variables = vars # Variables end |
Instance Attribute Details
#decls ⇒ Object (readonly)
Returns the value of attribute decls.
153 154 155 |
# File 'lib/bricolage/parameters.rb', line 153 def decls @decls end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
154 155 156 |
# File 'lib/bricolage/parameters.rb', line 154 def values @values end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
155 156 157 |
# File 'lib/bricolage/parameters.rb', line 155 def variables @variables end |
Class Method Details
.empty(decls) ⇒ Object
143 144 145 |
# File 'lib/bricolage/parameters.rb', line 143 def IntermediateValues.empty(decls) new(decls, {}, Variables.new) end |
.union(decls, *vals_list) ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/bricolage/parameters.rb', line 135 def IntermediateValues.union(decls, *vals_list) result = empty(decls) vals_list.each do |vals| result.update vals end result end |
Instance Method Details
#[](name) ⇒ Object
157 158 159 |
# File 'lib/bricolage/parameters.rb', line 157 def [](name) @values[name] end |
#[]=(name, value) ⇒ Object
161 162 163 |
# File 'lib/bricolage/parameters.rb', line 161 def []=(name, value) @values[name] = value end |
#keys ⇒ Object
165 166 167 |
# File 'lib/bricolage/parameters.rb', line 165 def keys @values.keys end |
#resolve(ctx, vars) ⇒ Object
177 178 179 180 181 |
# File 'lib/bricolage/parameters.rb', line 177 def resolve(ctx, vars) materialized = materialize(ctx, vars) resolved = resolved_variables(materialized, vars) Parameters.new(@decls, materialized, resolved, ctx) end |
#update(other) ⇒ Object
169 170 171 172 173 174 175 |
# File 'lib/bricolage/parameters.rb', line 169 def update(other) unless @decls == other.decls raise "[BUG] merging IntermediateValues with different paramdecl: #{self.inspect} - #{other.inspect}" end @values.update other.values @variables.update other.variables end |