Class: EventEngine::EventDefinition::Schemas::Schema

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

Instance Method Summary collapse

Instance Attribute Details

#domainObject

Returns the value of attribute domain

Returns:

  • (Object)

    the current value of domain



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def domain
  @domain
end

#event_nameObject

Returns the value of attribute event_name

Returns:

  • (Object)

    the current value of event_name



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def event_name
  @event_name
end

#event_typeObject

Returns the value of attribute event_type

Returns:

  • (Object)

    the current value of event_type



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def event_type
  @event_type
end

#event_versionObject

Returns the value of attribute event_version

Returns:

  • (Object)

    the current value of event_version



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def event_version
  @event_version
end

#optional_inputsObject

Returns the value of attribute optional_inputs

Returns:

  • (Object)

    the current value of optional_inputs



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def optional_inputs
  @optional_inputs
end

#payload_fieldsObject

Returns the value of attribute payload_fields

Returns:

  • (Object)

    the current value of payload_fields



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def payload_fields
  @payload_fields
end

#process_typeObject

Returns the value of attribute process_type

Returns:

  • (Object)

    the current value of process_type



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def process_type
  @process_type
end

#required_inputsObject

Returns the value of attribute required_inputs

Returns:

  • (Object)

    the current value of required_inputs



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def required_inputs
  @required_inputs
end

#subjectObject

Returns the value of attribute subject

Returns:

  • (Object)

    the current value of subject



12
13
14
# File 'lib/event_engine/event_definition/schemas.rb', line 12

def subject
  @subject
end

Instance Method Details

#fingerprintString

Returns a SHA256 fingerprint of the schema’s canonical representation. Used to detect schema changes and trigger version bumps.

Returns:

  • (String)

    hex-encoded SHA256 digest



29
30
31
32
33
# File 'lib/event_engine/event_definition/schemas.rb', line 29

def fingerprint
  Digest::SHA256.hexdigest(
    canonical_representation
  )
end

#to_rubyString

Serializes the schema to a Ruby source string for the schema file.

Returns:

  • (String)


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