Class: Schemurai::Internal::SchemaGraph::Resource
- Inherits:
-
Object
- Object
- Schemurai::Internal::SchemaGraph::Resource
- Defined in:
- lib/schemurai/schema_graph.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #add(node) ⇒ Object
-
#initialize(uri, root) ⇒ Resource
constructor
A new instance of Resource.
- #node_at(pointer) ⇒ Object
- #nodes ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
55 56 57 |
# File 'lib/schemurai/schema_graph.rb', line 55 def root @root end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
55 56 57 |
# File 'lib/schemurai/schema_graph.rb', line 55 def uri @uri end |
Instance Method Details
#add(node) ⇒ Object
63 64 65 66 |
# File 'lib/schemurai/schema_graph.rb', line 63 def add(node) (@nodes ||= {})[node.resource_path] = node unless node.equal?(root) node.resource = self unless node.resource.equal?(self) end |
#node_at(pointer) ⇒ Object
68 69 70 71 72 |
# File 'lib/schemurai/schema_graph.rb', line 68 def node_at(pointer) return root if pointer.empty? @nodes&.[](pointer) end |
#nodes ⇒ Object
74 75 76 |
# File 'lib/schemurai/schema_graph.rb', line 74 def nodes @nodes || EMPTY_NODES end |