Class: OllamaAgent::Synthesis::EventSchemaRegistry
- Inherits:
-
Object
- Object
- OllamaAgent::Synthesis::EventSchemaRegistry
- Defined in:
- lib/ollama_agent/synthesis/event_schema_registry.rb
Overview
Minimal JSON-schema-shaped registry (required + property types) for integration payloads.
Constant Summary collapse
- ALLOWED_TYPES =
%w[string integer array object boolean].freeze
Instance Method Summary collapse
-
#initialize ⇒ EventSchemaRegistry
constructor
A new instance of EventSchemaRegistry.
- #known_events ⇒ Object
- #register(event_name:, schema:) ⇒ Object
- #validate(event_name:, payload:) ⇒ Object
Constructor Details
#initialize ⇒ EventSchemaRegistry
Returns a new instance of EventSchemaRegistry.
12 13 14 |
# File 'lib/ollama_agent/synthesis/event_schema_registry.rb', line 12 def initialize @schemas = {} end |
Instance Method Details
#known_events ⇒ Object
29 30 31 |
# File 'lib/ollama_agent/synthesis/event_schema_registry.rb', line 29 def known_events @schemas.keys.sort end |
#register(event_name:, schema:) ⇒ Object
16 17 18 |
# File 'lib/ollama_agent/synthesis/event_schema_registry.rb', line 16 def register(event_name:, schema:) @schemas[event_name.to_s] = normalize_schema(schema) end |
#validate(event_name:, payload:) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/ollama_agent/synthesis/event_schema_registry.rb', line 20 def validate(event_name:, payload:) name = event_name.to_s raise UnknownEvent, name unless @schemas.key?(name) schema = @schemas[name] errors = validation_errors(schema, payload) { valid: errors.empty?, errors: errors } end |