Class: PgEventstore::Event
- Inherits:
-
Object
- Object
- PgEventstore::Event
- Defined in:
- lib/pg_eventstore/event.rb
Constant Summary collapse
- LINK_TYPE =
Returns a type of link event.
'$>'
Instance Attribute Summary collapse
-
#created_at ⇒ Time?
A timestamp an event was created at.
-
#data ⇒ Hash
Event’s data.
-
#global_position ⇒ Integer
Event’s position in “all” stream.
-
#id ⇒ String
UUIDv4 string.
-
#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_id ⇒ String?
UUIDv4 of an event the current event points to.
-
#link_partition_id ⇒ Integer?
A partition id of an event the link event points to.
-
#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
Implements comparison of ‘PgEventstore::Event`-s.
-
#link? ⇒ Boolean
Detect whether an event is a link event.
-
#system? ⇒ Boolean
Detect whether an event is a system event.
Methods included from PgEventstore::Extensions::OptionsExtension
included, #initialize, #options_hash, #readonly!, #readonly?
Instance Attribute Details
#created_at ⇒ Time?
Returns a timestamp an event was created at.
45 |
# File 'lib/pg_eventstore/event.rb', line 45 attribute(:created_at) |
#data ⇒ Hash
Returns event’s data.
27 |
# File 'lib/pg_eventstore/event.rb', line 27 attribute(:data) { {} } |
#global_position ⇒ Integer
Returns event’s position in “all” stream.
18 |
# File 'lib/pg_eventstore/event.rb', line 18 attribute(:global_position) |
#id ⇒ String
Returns UUIDv4 string.
12 |
# File 'lib/pg_eventstore/event.rb', line 12 attribute(:id) |
#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.
42 |
# File 'lib/pg_eventstore/event.rb', line 42 attribute(:link) |
#link_id ⇒ String?
Returns UUIDv4 of an event the current event points to. If it is not nil, then the current event is a link.
34 |
# File 'lib/pg_eventstore/event.rb', line 34 attribute(:link_id) |
#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.
38 |
# File 'lib/pg_eventstore/event.rb', line 38 attribute(:link_partition_id) |
#metadata ⇒ Hash
Returns event’s metadata.
30 |
# File 'lib/pg_eventstore/event.rb', line 30 attribute(:metadata) { {} } |
#stream ⇒ PgEventstore::Stream?
Returns event’s stream.
21 |
# File 'lib/pg_eventstore/event.rb', line 21 attribute(:stream) |
#stream_revision ⇒ Integer
Returns a revision of an event inside event’s stream.
24 |
# File 'lib/pg_eventstore/event.rb', line 24 attribute(:stream_revision) |
#type ⇒ String
Returns event type.
15 |
# File 'lib/pg_eventstore/event.rb', line 15 attribute(:type) { self.class.name } |
Instance Method Details
#==(other) ⇒ Boolean
Implements comparison of ‘PgEventstore::Event`-s. Two events matches if all of their attributes matches
50 51 52 53 54 |
# File 'lib/pg_eventstore/event.rb', line 50 def ==(other) return false unless other.is_a?(PgEventstore::Event) attributes_hash.except(:link) == other.attributes_hash.except(:link) end |
#link? ⇒ Boolean
Detect whether an event is a link event
58 59 60 |
# File 'lib/pg_eventstore/event.rb', line 58 def link? !link_id.nil? end |
#system? ⇒ Boolean
Detect whether an event is a system event
64 65 66 |
# File 'lib/pg_eventstore/event.rb', line 64 def system? type.start_with?('$') end |