class ComputedModel::DepGraph::Edge
An edge in the dependency graph. That is, a dependency declaration in a computed model.
Attributes
name[R]
@return [Symbol] the name of the dependency (not the dependent)
spec[R]
@return [Array] an auxiliary data called subfield selectors
Public Class Methods
new(name, spec)
click to toggle source
@param name [Symbol] the name of the dependency (not the dependent) @param spec [Array] an auxiliary data called subfield selectors
# File lib/computed_model/dep_graph.rb, line 160 def initialize(name, spec) @name = name @spec = Array(spec) end
Public Instance Methods
evaluate(subfields)
click to toggle source
@param subfields [Array] incoming list of subfield selectors @return [Array, nil]
# 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