Class: Woods::Storage::GraphStore::Memory
- Inherits:
-
Object
- Object
- Woods::Storage::GraphStore::Memory
- Includes:
- Interface
- Defined in:
- lib/woods/storage/graph_store.rb
Overview
In-memory graph store wrapping the existing DependencyGraph.
Delegates all operations to DependencyGraph, providing a consistent storage interface.
Instance Attribute Summary collapse
-
#graph ⇒ Object
readonly
The wrapped graph.
Instance Method Summary collapse
- #affected_by(changed_files, max_depth: nil) ⇒ Object
- #by_type(type) ⇒ Object
- #dependencies_of(identifier) ⇒ Object
- #dependents_of(identifier) ⇒ Object
-
#durable? ⇒ Boolean
Always
false— the in-memory adapter is rebuilt on every process boot and owns none of its state across restarts. -
#initialize(graph = nil) ⇒ Memory
constructor
A new instance of Memory.
- #pagerank(damping: 0.85, iterations: 20) ⇒ Object
-
#register(unit) ⇒ Object
Register a unit in the graph.
-
#replace_graph(graph) ⇒ void
Replace the wrapped graph in place.
Constructor Details
#initialize(graph = nil) ⇒ Memory
Returns a new instance of Memory.
103 104 105 |
# File 'lib/woods/storage/graph_store.rb', line 103 def initialize(graph = nil) @graph = graph || DependencyGraph.new end |
Instance Attribute Details
#graph ⇒ Object (readonly)
The wrapped graph. Exposed so reload paths can peel the raw graph out of a freshly-hydrated wrapper and #replace_graph it into the live one.
100 101 102 |
# File 'lib/woods/storage/graph_store.rb', line 100 def graph @graph end |
Instance Method Details
#affected_by(changed_files, max_depth: nil) ⇒ Object
136 137 138 |
# File 'lib/woods/storage/graph_store.rb', line 136 def affected_by(changed_files, max_depth: nil) @graph.affected_by(changed_files, max_depth: max_depth) end |
#by_type(type) ⇒ Object
141 142 143 |
# File 'lib/woods/storage/graph_store.rb', line 141 def by_type(type) @graph.units_of_type(type) end |
#dependencies_of(identifier) ⇒ Object
126 127 128 |
# File 'lib/woods/storage/graph_store.rb', line 126 def dependencies_of(identifier) @graph.dependencies_of(identifier) end |
#dependents_of(identifier) ⇒ Object
131 132 133 |
# File 'lib/woods/storage/graph_store.rb', line 131 def dependents_of(identifier) @graph.dependents_of(identifier) end |
#durable? ⇒ Boolean
Returns always false — the in-memory adapter is rebuilt on every process boot and owns none of its state across restarts.
153 154 155 |
# File 'lib/woods/storage/graph_store.rb', line 153 def durable? false end |
#pagerank(damping: 0.85, iterations: 20) ⇒ Object
146 147 148 |
# File 'lib/woods/storage/graph_store.rb', line 146 def pagerank(damping: 0.85, iterations: 20) @graph.pagerank(damping: damping, iterations: iterations) end |
#register(unit) ⇒ Object
Register a unit in the graph.
110 111 112 |
# File 'lib/woods/storage/graph_store.rb', line 110 def register(unit) @graph.register(unit) end |
#replace_graph(graph) ⇒ void
This method returns an undefined value.
Replace the wrapped graph in place. Used by the MCP reload tool so tool closures that captured this wrapper see a fresh graph without needing to re-instantiate the wrapper (and break the closure references).
121 122 123 |
# File 'lib/woods/storage/graph_store.rb', line 121 def replace_graph(graph) @graph = graph end |