Module: ActiveCypher::Bolt::Messaging
- Defined in:
- lib/active_cypher/bolt/messaging.rb
Defined Under Namespace
Classes: Begin, Commit, Discard, Failure, Goodbye, Hello, Ignored, Logoff, Logon, Message, Pull, Record, Reset, Rollback, Route, Run, Success, Telemetry
Class Method Summary collapse
-
.for_signature(signature, *fields) ⇒ Message
Lookup-and-instantiate based on signature + raw fields.
-
.normalize_map(map) ⇒ Object
Normalize any metadata or parameters map.
-
.register(subclass) ⇒ Object
Register a subclass if it defines SIGNATURE.
-
.registry ⇒ Object
For introspection.
Class Method Details
.for_signature(signature, *fields) ⇒ Message
Lookup-and-instantiate based on signature + raw fields
25 26 27 28 29 30 31 |
# File 'lib/active_cypher/bolt/messaging.rb', line 25 def for_signature(signature, *fields) if (klass = @registry[signature]) klass.new(*fields) else Message.new(signature, fields) end end |
.normalize_map(map) ⇒ Object
Normalize any metadata or parameters map
42 43 44 |
# File 'lib/active_cypher/bolt/messaging.rb', line 42 def normalize_map(map) (map || {}).with_indifferent_access end |
.register(subclass) ⇒ Object
Register a subclass if it defines SIGNATURE
34 35 36 37 38 39 |
# File 'lib/active_cypher/bolt/messaging.rb', line 34 def register(subclass) return unless subclass.const_defined?(:SIGNATURE) sig = subclass.const_get(:SIGNATURE) @registry[sig] = subclass end |
.registry ⇒ Object
For introspection
16 17 18 |
# File 'lib/active_cypher/bolt/messaging.rb', line 16 def registry @registry.dup end |