Class: ComputedModel::DepGraph::Edge Private
- Inherits:
-
Object
- Object
- ComputedModel::DepGraph::Edge
- Defined in:
- lib/computed_model/dep_graph.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An edge in the dependency graph. That is, a dependency declaration in a computed model.
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
private
The name of the dependency (not the dependent).
-
#spec ⇒ Array
readonly
private
An auxiliary data called subfield selectors.
Instance Method Summary collapse
- #evaluate(subfields) ⇒ Array? private
-
#initialize(name, spec) ⇒ Edge
constructor
private
A new instance of Edge.
Constructor Details
#initialize(name, spec) ⇒ Edge
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Edge.
160 161 162 163 |
# File 'lib/computed_model/dep_graph.rb', line 160 def initialize(name, spec) @name = name @spec = Array(spec) end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the name of the dependency (not the dependent).
154 155 156 |
# File 'lib/computed_model/dep_graph.rb', line 154 def name @name end |
#spec ⇒ Array (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an auxiliary data called subfield selectors.
156 157 158 |
# File 'lib/computed_model/dep_graph.rb', line 156 def spec @spec end |
Instance Method Details
#evaluate(subfields) ⇒ Array?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/computed_model/dep_graph.rb', line 167 def evaluate(subfields) return @spec if @spec.all? { |specelem| !specelem.respond_to?(:call) } evaluated = [] @spec.each do |specelem| if specelem.respond_to?(:call) ret = specelem.call(subfields) if ret.is_a?(Array) evaluated.push(*ret) else evaluated << ret end else evaluated << specelem end end evaluated end |