Class: Rage::OpenAPI::Nodes::Root
- Inherits:
-
Object
- Object
- Rage::OpenAPI::Nodes::Root
- Defined in:
- lib/rage/openapi/nodes/root.rb
Overview
Represents a tree of method nodes. The tree consists of:
- a root node;
- method nodes, each of which represents an action in a controller;
- parent nodes attached to one or several method nodes;
A method node together with its parent nodes represent a complete inheritance chain.
Nodes::Root
|
Nodes::Parent<ApplicationController>
|
Nodes::Parent<Api::BaseController>
/ \
Nodes::Parent<Api::V1::UsersController> Nodes::Parent<Api::V2::UsersController>
/ \ |
Nodes::Method<index> Nodes::Method<show> Nodes::Method<show>
Instance Attribute Summary collapse
-
#leaves ⇒ Object
readonly
Returns the value of attribute leaves.
-
#title ⇒ Object
Returns the value of attribute title.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize ⇒ Root
constructor
A new instance of Root.
- #new_method_node(controller, action, parent_nodes) ⇒ Object
- #new_parent_node(controller) ⇒ Object
- #parent_nodes ⇒ Object
Constructor Details
#initialize ⇒ Root
Returns a new instance of Root.
26 27 28 29 |
# File 'lib/rage/openapi/nodes/root.rb', line 26 def initialize @parent_nodes_cache = {} @leaves = [] end |
Instance Attribute Details
#leaves ⇒ Object (readonly)
Returns the value of attribute leaves.
23 24 25 |
# File 'lib/rage/openapi/nodes/root.rb', line 23 def leaves @leaves end |
#title ⇒ Object
Returns the value of attribute title.
24 25 26 |
# File 'lib/rage/openapi/nodes/root.rb', line 24 def title @title end |
#version ⇒ Object
Returns the value of attribute version.
24 25 26 |
# File 'lib/rage/openapi/nodes/root.rb', line 24 def version @version end |
Instance Method Details
#new_method_node(controller, action, parent_nodes) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/rage/openapi/nodes/root.rb', line 35 def new_method_node(controller, action, parent_nodes) node = Rage::OpenAPI::Nodes::Method.new(controller, action, parent_nodes) @leaves << node node end |
#new_parent_node(controller) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/rage/openapi/nodes/root.rb', line 42 def new_parent_node(controller) @parent_nodes_cache[controller] ||= begin node = Rage::OpenAPI::Nodes::Parent.new(self, controller) yield(node) node end end |
#parent_nodes ⇒ Object
31 32 33 |
# File 'lib/rage/openapi/nodes/root.rb', line 31 def parent_nodes @parent_nodes_cache.values end |