Class: CallMap::CallNode
- Inherits:
-
Object
- Object
- CallMap::CallNode
- Defined in:
- lib/call_map/call_node.rb
Overview
A node in the call tree. Holds the definition (if resolved), the original method call, and child nodes representing calls made from within this method.
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#method_call ⇒ Object
readonly
Returns the value of attribute method_call.
Instance Method Summary collapse
- #circular? ⇒ Boolean
-
#initialize(definition: nil, method_call: nil, children: [], circular: false) ⇒ CallNode
constructor
A new instance of CallNode.
-
#label ⇒ Object
Human-readable label for this node.
- #resolved? ⇒ Boolean
Constructor Details
#initialize(definition: nil, method_call: nil, children: [], circular: false) ⇒ CallNode
Returns a new instance of CallNode.
11 12 13 14 15 16 |
# File 'lib/call_map/call_node.rb', line 11 def initialize(definition: nil, method_call: nil, children: [], circular: false) @definition = definition @method_call = method_call @children = children @circular = circular end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
18 19 20 |
# File 'lib/call_map/call_node.rb', line 18 def children @children end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
18 19 20 |
# File 'lib/call_map/call_node.rb', line 18 def definition @definition end |
#method_call ⇒ Object (readonly)
Returns the value of attribute method_call.
18 19 20 |
# File 'lib/call_map/call_node.rb', line 18 def method_call @method_call end |
Instance Method Details
#circular? ⇒ Boolean
24 25 26 |
# File 'lib/call_map/call_node.rb', line 24 def circular? @circular end |
#label ⇒ Object
Human-readable label for this node. A callback-originated node keeps its callback label (e.g. "before_action set_order") even when resolved, so tree output can distinguish it from a plain call. An unresolved call that points outside the indexed app code is marked as a framework leaf.
32 33 34 35 36 37 38 |
# File 'lib/call_map/call_node.rb', line 32 def label base = base_label return "#{base} [circular]" if circular? return "#{base} [framework]" if !resolved? && method_call&.framework_leaf? base end |
#resolved? ⇒ Boolean
20 21 22 |
# File 'lib/call_map/call_node.rb', line 20 def resolved? !definition.nil? end |