Module: Phronomy::Graph
- Defined in:
- lib/phronomy.rb,
lib/phronomy/graph.rb,
lib/phronomy/graph/state.rb,
lib/phronomy/graph/state_graph.rb,
lib/phronomy/graph/parallel_node.rb,
lib/phronomy/graph/compiled_graph.rb
Overview
Namespace for graph-related classes (StateGraph, State, ParallelNode, …). Also serves as the registry for State classes that may be serialized to external stores (Redis, DB). Call +register_state_class+ at application startup so that only known classes can be deserialized.
Defined Under Namespace
Modules: State Classes: CompiledGraph, ParallelNode, StateGraph, TimeoutError
Class Attribute Summary collapse
-
.state_class_registry ⇒ Hash{String => Class}?
readonly
Returns the current registry Hash, or nil when no class has been registered.
Class Method Summary collapse
-
.register_state_class(*classes) ⇒ Object
Register one or more State classes that are allowed to be deserialized by StateStore backends.
-
.reset_state_class_registry! ⇒ Object
Clears the registry.
Class Attribute Details
.state_class_registry ⇒ Hash{String => Class}? (readonly)
Returns the current registry Hash, or nil when no class has been registered.
68 69 70 |
# File 'lib/phronomy.rb', line 68 def state_class_registry @state_class_registry end |
Class Method Details
.register_state_class(*classes) ⇒ Object
Register one or more State classes that are allowed to be deserialized by StateStore backends. When at least one class is registered, only registered classes will be accepted by +StateStore::Base#safe_state_class+.
Call this once at application startup (e.g. in a Rails initializer).
56 57 58 59 60 61 62 63 64 |
# File 'lib/phronomy.rb', line 56 def register_state_class(*classes) @registry_mutex.synchronize do @state_class_registry ||= {} classes.each do |klass| raise ArgumentError, "#{klass.inspect} is not a Class" unless klass.is_a?(Class) @state_class_registry[klass.name] = klass end end end |
.reset_state_class_registry! ⇒ Object
Clears the registry. Primarily used in tests.
71 72 73 |
# File 'lib/phronomy.rb', line 71 def reset_state_class_registry! @registry_mutex.synchronize { @state_class_registry = nil } end |