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.
16 17 18 |
# File 'lib/schemurai/schema_graph.rb', line 16 def root @root end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
16 17 18 |
# File 'lib/schemurai/schema_graph.rb', line 16 def uri @uri end |
Instance Method Details
#add(node) ⇒ Object
24 25 26 27 |
# File 'lib/schemurai/schema_graph.rb', line 24 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
29 30 31 32 33 |
# File 'lib/schemurai/schema_graph.rb', line 29 def node_at(pointer) return root if pointer.empty? @nodes&.[](pointer) end |
#nodes ⇒ Object
35 36 37 |
# File 'lib/schemurai/schema_graph.rb', line 35 def nodes @nodes || EMPTY_NODES end |