Class: ComputedModel::DepGraph::Node Private
- Inherits:
-
Object
- Object
- ComputedModel::DepGraph::Node
- 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.
A node in the dependency graph. That is, a field in a computed model.
Instance Attribute Summary collapse
-
#edges ⇒ Hash{Symbol => Edge}
readonly
private
Edges indexed by its name.
-
#name ⇒ Symbol
readonly
private
The name of the node.
-
#type ⇒ Symbol
readonly
private
The type of the node.
Instance Method Summary collapse
-
#initialize(type, name, edges) ⇒ Node
constructor
private
A new instance of Node.
Constructor Details
#initialize(type, name, edges) ⇒ Node
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 Node.
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/computed_model/dep_graph.rb', line 139 def initialize(type, name, edges) raise ArgumentError, "invalid type: #{type.inspect}" unless ALLOWED_TYPES.include?(type) edges = ComputedModel.normalize_dependencies(edges) raise ArgumentError, "primary field cannot have dependency: #{name}" if type == :primary && edges.size > 0 @type = type @name = name @edges = edges.map { |k, v| [k, Edge.new(k, v)] }.to_h.freeze end |
Instance Attribute Details
#edges ⇒ Hash{Symbol => Edge} (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 edges indexed by its name.
131 132 133 |
# File 'lib/computed_model/dep_graph.rb', line 131 def edges @edges end |
#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 node.
129 130 131 |
# File 'lib/computed_model/dep_graph.rb', line 129 def name @name end |
#type ⇒ 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 type of the node. One of :computed, :loaded and :primary.
127 128 129 |
# File 'lib/computed_model/dep_graph.rb', line 127 def type @type end |