Class: Bricolage::Parameters::IntermediateValues

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#declsObject (readonly)

Returns the value of attribute decls.



153
154
155
# File 'lib/bricolage/parameters.rb', line 153

def decls
  @decls
end

#valuesObject (readonly)

Returns the value of attribute values.



154
155
156
# File 'lib/bricolage/parameters.rb', line 154

def values
  @values
end

#variablesObject (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

#keysObject



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