Class: EventEngine::EventDefinition::Schemas::Schema
- Inherits:
-
Struct
- Object
- Struct
- EventEngine::EventDefinition::Schemas::Schema
- Defined in:
- lib/event_engine/event_definition/schemas.rb
Overview
Immutable representation of a compiled event schema. Holds the event identity, inputs, and payload field definitions. Used both at development time (compilation) and runtime (registry).
Instance Attribute Summary collapse
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#event_name ⇒ Object
Returns the value of attribute event_name.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#event_version ⇒ Object
Returns the value of attribute event_version.
-
#optional_inputs ⇒ Object
Returns the value of attribute optional_inputs.
-
#payload_fields ⇒ Object
Returns the value of attribute payload_fields.
-
#process_type ⇒ Object
Returns the value of attribute process_type.
-
#required_inputs ⇒ Object
Returns the value of attribute required_inputs.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
-
#fingerprint ⇒ String
Returns a SHA256 fingerprint of the schema’s canonical representation.
-
#to_ruby ⇒ String
Serializes the schema to a Ruby source string for the schema file.
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def domain @domain end |
#event_name ⇒ Object
Returns the value of attribute event_name
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def event_name @event_name end |
#event_type ⇒ Object
Returns the value of attribute event_type
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def event_type @event_type end |
#event_version ⇒ Object
Returns the value of attribute event_version
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def event_version @event_version end |
#optional_inputs ⇒ Object
Returns the value of attribute optional_inputs
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def optional_inputs @optional_inputs end |
#payload_fields ⇒ Object
Returns the value of attribute payload_fields
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def payload_fields @payload_fields end |
#process_type ⇒ Object
Returns the value of attribute process_type
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def process_type @process_type end |
#required_inputs ⇒ Object
Returns the value of attribute required_inputs
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def required_inputs @required_inputs end |
#subject ⇒ Object
Returns the value of attribute subject
12 13 14 |
# File 'lib/event_engine/event_definition/schemas.rb', line 12 def subject @subject end |
Instance Method Details
#fingerprint ⇒ String
Returns a SHA256 fingerprint of the schema’s canonical representation. Used to detect schema changes and trigger version bumps.
29 30 31 32 33 |
# File 'lib/event_engine/event_definition/schemas.rb', line 29 def fingerprint Digest::SHA256.hexdigest( canonical_representation ) end |
#to_ruby ⇒ String
Serializes the schema to a Ruby source string for the schema file.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/event_engine/event_definition/schemas.rb', line 38 def to_ruby <<~RUBY.strip EventEngine::EventDefinition::Schema.new( event_name: #{event_name.inspect}, event_version: #{event_version.inspect}, event_type: #{event_type.inspect}, process_type: #{process_type.inspect}, subject: #{subject.inspect}, domain: #{domain.inspect}, required_inputs: #{required_inputs.inspect}, optional_inputs: #{optional_inputs.inspect}, payload_fields: [#{payload_fields.map { |h| ruby_hash(h) }.join(", ")}] ) RUBY end |