Class: TCB::Envelope
- Inherits:
-
Data
- Object
- Data
- TCB::Envelope
- Defined in:
- lib/tcb/envelope.rb
Instance Attribute Summary collapse
-
#causation_id ⇒ Object
readonly
Returns the value of attribute causation_id.
-
#correlation_id ⇒ Object
readonly
Returns the value of attribute correlation_id.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#event_id ⇒ Object
readonly
Returns the value of attribute event_id.
-
#occurred_at ⇒ Object
readonly
Returns the value of attribute occurred_at.
-
#stream_id ⇒ Object
readonly
Returns the value of attribute stream_id.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Attribute Details
#causation_id ⇒ Object (readonly)
Returns the value of attribute causation_id
6 7 8 |
# File 'lib/tcb/envelope.rb', line 6 def causation_id @causation_id end |
#correlation_id ⇒ Object (readonly)
Returns the value of attribute correlation_id
6 7 8 |
# File 'lib/tcb/envelope.rb', line 6 def correlation_id @correlation_id end |
#event ⇒ Object (readonly)
Returns the value of attribute event
6 7 8 |
# File 'lib/tcb/envelope.rb', line 6 def event @event end |
#event_id ⇒ Object (readonly)
Returns the value of attribute event_id
6 7 8 |
# File 'lib/tcb/envelope.rb', line 6 def event_id @event_id end |
#occurred_at ⇒ Object (readonly)
Returns the value of attribute occurred_at
6 7 8 |
# File 'lib/tcb/envelope.rb', line 6 def occurred_at @occurred_at end |
#stream_id ⇒ Object (readonly)
Returns the value of attribute stream_id
6 7 8 |
# File 'lib/tcb/envelope.rb', line 6 def stream_id @stream_id end |
#version ⇒ Object (readonly)
Returns the value of attribute version
6 7 8 |
# File 'lib/tcb/envelope.rb', line 6 def version @version end |
Class Method Details
.coerce(event_or_envelope) ⇒ Object
27 28 29 |
# File 'lib/tcb/envelope.rb', line 27 def self.coerce(event_or_envelope) event_or_envelope.is_a?(self) ? event_or_envelope : wrap(event_or_envelope) end |
.wrap(event, correlation_id: nil, causation_id: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tcb/envelope.rb', line 15 def self.wrap(event, correlation_id: nil, causation_id: nil) new( event: event, event_id: SecureRandom.uuid, stream_id: nil, version: nil, occurred_at: Time.now, correlation_id: correlation_id, causation_id: causation_id ) end |