Class: Woods::Storage::GraphStore::Memory

Inherits:
Object
  • Object
show all
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.

Examples:

store = Memory.new
store.register(user_unit)
store.dependencies_of("User")  # => ["Organization"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph = nil) ⇒ Memory

Returns a new instance of Memory.

Parameters:

  • graph (DependencyGraph, nil) (defaults to: nil)

    Existing graph to wrap, or nil to create a new one



103
104
105
# File 'lib/woods/storage/graph_store.rb', line 103

def initialize(graph = nil)
  @graph = graph || DependencyGraph.new
end

Instance Attribute Details

#graphObject (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

See Also:



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.

Returns:

  • (Boolean)

    always false — the in-memory adapter is rebuilt on every process boot and owns none of its state across restarts.

See Also:



153
154
155
# File 'lib/woods/storage/graph_store.rb', line 153

def durable?
  false
end

#pagerank(damping: 0.85, iterations: 20) ⇒ Object

See Also:



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.

Parameters:



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).

Parameters:



121
122
123
# File 'lib/woods/storage/graph_store.rb', line 121

def replace_graph(graph)
  @graph = graph
end