Class: PgEventstore::Event
- Inherits:
-
Object
- Object
- PgEventstore::Event
- Defined in:
- lib/pg_eventstore/event.rb,
sig/pg_eventstore/event.rbs
Constant Summary collapse
- LINK_TYPE =
Returns a type of link event.
'$>'- SYSTEM_SYMBOL =
"\u2592"- MARKERS_METADATA_KEY =
"#{SYSTEM_SYMBOL}m".freeze
- PRIMARY_TABLE_NAME =
'events'- NON_EXISTING_EVENT_REVISION =
-1
- SYSTEM_KEY_PREFIX =
Instance Attribute Summary collapse
-
#causation_id ⇒ String?
UUIDv7.
- #caused_by ⇒ PgEventstore::Event?
-
#correlation_id ⇒ String?
UUIDv7.
-
#created_at ⇒ Time?
A timestamp an event was created at.
-
#data ⇒ Hash
Event's data.
-
#feature_markers ⇒ Array<FeatureMarker>
Feature-specific markers that can't be put under #markers.
-
#global_position ⇒ Integer
Event's position in "all" stream.
-
#id ⇒ String
UUIDv7.
-
#link ⇒ PgEventstore::Event?
When resolve_link_tos: true option is provided during the read of events and event is a link event - this attribute will be pointing on that link.
-
#link_global_position ⇒ Integer?
Global_position of an event the current event points to.
-
#link_partition_id ⇒ Integer?
A partition id of an event the link event points to.
-
#markers ⇒ Array<String>
Event markers.
-
#metadata ⇒ Hash
Event's metadata.
-
#stream ⇒ PgEventstore::Stream?
Event's stream.
-
#stream_revision ⇒ Integer
A revision of an event inside event's stream.
-
#type ⇒ String
Event type.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Implements comparison of
PgEventstore::Event-s. - #dup ⇒ self
- #hash ⇒ Integer
- #init_default_values ⇒ void
-
#initialize ⇒ Event
constructor
A new instance of Event.
-
#link? ⇒ Boolean
Detect whether an event is a link event.
- #options_hash ⇒ ::Hash[untyped, untyped]
- #readonly! ⇒ Boolean
- #readonly? ⇒ Boolean
- #readonly_error ⇒ void
-
#system? ⇒ Boolean
Detect whether an event is a system event.
Methods included from PgEventstore::Extensions::OptionsExtension
Constructor Details
#initialize ⇒ Event
Returns a new instance of Event.
18 |
# File 'sig/pg_eventstore/event.rbs', line 18
def initialize: (**untyped options) -> void
|
Instance Attribute Details
#causation_id ⇒ String?
Returns UUIDv7.
68 |
# File 'lib/pg_eventstore/event.rb', line 68 attribute(:causation_id) |
#caused_by ⇒ PgEventstore::Event?
62 |
# File 'lib/pg_eventstore/event.rb', line 62 attribute(:caused_by) |
#correlation_id ⇒ String?
Returns UUIDv7.
65 |
# File 'lib/pg_eventstore/event.rb', line 65 attribute(:correlation_id) |
#created_at ⇒ Time?
Returns a timestamp an event was created at.
59 |
# File 'lib/pg_eventstore/event.rb', line 59 attribute(:created_at) |
#data ⇒ Hash
Returns event's data.
35 |
# File 'lib/pg_eventstore/event.rb', line 35 attribute(:data) { {} } |
#feature_markers ⇒ Array<FeatureMarker>
Returns feature-specific markers that can't be put under #markers.
41 |
# File 'lib/pg_eventstore/event.rb', line 41 attribute(:feature_markers) { [] } |
#global_position ⇒ Integer
Returns event's position in "all" stream.
26 |
# File 'lib/pg_eventstore/event.rb', line 26 attribute(:global_position) |
#id ⇒ String
Returns UUIDv7.
20 |
# File 'lib/pg_eventstore/event.rb', line 20 attribute(:id) { SecureRandom.uuid_v7 } |
#link ⇒ PgEventstore::Event?
Returns when resolve_link_tos: true option is provided during the read of events and event is a link event - this attribute will be pointing on that link.
56 |
# File 'lib/pg_eventstore/event.rb', line 56 attribute(:link) |
#link_global_position ⇒ Integer?
Returns global_position of an event the current event points to. If it is not nil, then the current event is a link.
48 |
# File 'lib/pg_eventstore/event.rb', line 48 attribute(:link_global_position) |
#link_partition_id ⇒ Integer?
Returns a partition id of an event the link event points to. It is used to load original event when resolve_link_tos: true option is provided when reading events.
52 |
# File 'lib/pg_eventstore/event.rb', line 52 attribute(:link_partition_id) |
#markers ⇒ Array<String>
Returns event markers.
38 |
# File 'lib/pg_eventstore/event.rb', line 38 attribute(:markers) { [] } |
#metadata ⇒ Hash
Returns event's metadata.
44 |
# File 'lib/pg_eventstore/event.rb', line 44 attribute(:metadata) { {} } |
#stream ⇒ PgEventstore::Stream?
Returns event's stream.
29 |
# File 'lib/pg_eventstore/event.rb', line 29 attribute(:stream) |
#stream_revision ⇒ Integer
Returns a revision of an event inside event's stream.
32 |
# File 'lib/pg_eventstore/event.rb', line 32 attribute(:stream_revision) |
#type ⇒ String
Returns event type.
23 |
# File 'lib/pg_eventstore/event.rb', line 23 attribute(:type) { self.class.name } |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Implements comparison of PgEventstore::Event-s. Two events matches if all of their attributes matches
73 74 75 76 77 |
# File 'lib/pg_eventstore/event.rb', line 73 def ==(other) return false unless other.is_a?(PgEventstore::Event) attributes_hash.except(:link) == other.attributes_hash.except(:link) end |
#dup ⇒ self
98 99 100 |
# File 'lib/pg_eventstore/event.rb', line 98 def dup self.class.new(**Utils.deep_dup()) end |
#hash ⇒ Integer
87 88 89 |
# File 'lib/pg_eventstore/event.rb', line 87 def hash attributes_hash.except(:link).hash end |
#init_default_values ⇒ void
This method returns an undefined value.
28 |
# File 'sig/pg_eventstore/event.rbs', line 28
def init_default_values: (::Hash[untyped, untyped] options) -> void
|
#link? ⇒ Boolean
Detect whether an event is a link event
82 83 84 |
# File 'lib/pg_eventstore/event.rb', line 82 def link? !link_global_position.nil? end |
#options_hash ⇒ ::Hash[untyped, untyped]
20 |
# File 'sig/pg_eventstore/event.rbs', line 20
def options_hash: () -> ::Hash[untyped, untyped]
|
#readonly! ⇒ Boolean
22 |
# File 'sig/pg_eventstore/event.rbs', line 22
def readonly!: (Symbol opt_name) -> bool
|
#readonly? ⇒ Boolean
24 |
# File 'sig/pg_eventstore/event.rbs', line 24
def readonly?: (Symbol opt_name) -> bool
|
#readonly_error ⇒ void
This method returns an undefined value.
26 |
# File 'sig/pg_eventstore/event.rbs', line 26
def readonly_error: (Symbol opt_name) -> void
|
#system? ⇒ Boolean
Detect whether an event is a system event
93 94 95 |
# File 'lib/pg_eventstore/event.rb', line 93 def system? type.start_with?('$') end |