Class: EventEngine::Event

Inherits:
Struct
  • Object
show all
Defined in:
lib/event_engine/event.rb

Overview

A non-persisted, in-memory representation of an emitted event with a symbol-keyed payload. Passed to subscribers’ #handle(event) at every in-process level (1-3), and returned by the emitter for levels 1 and 2.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#aggregate_idObject

Returns the value of attribute aggregate_id

Returns:

  • (Object)

    the current value of aggregate_id



5
6
7
# File 'lib/event_engine/event.rb', line 5

def aggregate_id
  @aggregate_id
end

#aggregate_typeObject

Returns the value of attribute aggregate_type

Returns:

  • (Object)

    the current value of aggregate_type



5
6
7
# File 'lib/event_engine/event.rb', line 5

def aggregate_type
  @aggregate_type
end

#aggregate_versionObject

Returns the value of attribute aggregate_version

Returns:

  • (Object)

    the current value of aggregate_version



5
6
7
# File 'lib/event_engine/event.rb', line 5

def aggregate_version
  @aggregate_version
end

#domainObject

Returns the value of attribute domain

Returns:

  • (Object)

    the current value of domain



5
6
7
# File 'lib/event_engine/event.rb', line 5

def domain
  @domain
end

#event_nameObject

Returns the value of attribute event_name

Returns:

  • (Object)

    the current value of event_name



5
6
7
# File 'lib/event_engine/event.rb', line 5

def event_name
  @event_name
end

#event_typeObject

Returns the value of attribute event_type

Returns:

  • (Object)

    the current value of event_type



5
6
7
# File 'lib/event_engine/event.rb', line 5

def event_type
  @event_type
end

#event_versionObject

Returns the value of attribute event_version

Returns:

  • (Object)

    the current value of event_version



5
6
7
# File 'lib/event_engine/event.rb', line 5

def event_version
  @event_version
end

#idempotency_keyObject

Returns the value of attribute idempotency_key

Returns:

  • (Object)

    the current value of idempotency_key



5
6
7
# File 'lib/event_engine/event.rb', line 5

def idempotency_key
  @idempotency_key
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



5
6
7
# File 'lib/event_engine/event.rb', line 5

def 
  @metadata
end

#occurred_atObject

Returns the value of attribute occurred_at

Returns:

  • (Object)

    the current value of occurred_at



5
6
7
# File 'lib/event_engine/event.rb', line 5

def occurred_at
  @occurred_at
end

#payloadObject

Returns the value of attribute payload

Returns:

  • (Object)

    the current value of payload



5
6
7
# File 'lib/event_engine/event.rb', line 5

def payload
  @payload
end

#process_typeObject

Returns the value of attribute process_type

Returns:

  • (Object)

    the current value of process_type



5
6
7
# File 'lib/event_engine/event.rb', line 5

def process_type
  @process_type
end

#subjectObject

Returns the value of attribute subject

Returns:

  • (Object)

    the current value of subject



5
6
7
# File 'lib/event_engine/event.rb', line 5

def subject
  @subject
end

Class Method Details

.from(record) ⇒ Event

Builds an Event from a record responding to the same members (e.g. an OutboxEvent), normalizing the payload to symbol keys.

Parameters:

Returns:



26
27
28
29
30
# File 'lib/event_engine/event.rb', line 26

def self.from(record)
  attrs = members.to_h { |member| [member, record.public_send(member)] }
  attrs[:payload] = attrs[:payload].to_h.transform_keys(&:to_sym)
  new(**attrs)
end