Class: PgEventstore::Event

Inherits:
Object
  • Object
show all
Includes:
PgEventstore::Extensions::OptionsExtension
Defined in:
lib/pg_eventstore/event.rb

Constant Summary collapse

'$>'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PgEventstore::Extensions::OptionsExtension

included, #initialize, #options_hash, #readonly!, #readonly?

Instance Attribute Details

#created_atTime?

Returns a timestamp an event was created at.

Returns:

  • (Time, nil)

    a timestamp an event was created at



45
# File 'lib/pg_eventstore/event.rb', line 45

attribute(:created_at)

#dataHash

Returns event’s data.

Returns:

  • (Hash)

    event’s data



27
# File 'lib/pg_eventstore/event.rb', line 27

attribute(:data) { {} }

#global_positionInteger

Returns event’s position in “all” stream.

Returns:

  • (Integer)

    event’s position in “all” stream



18
# File 'lib/pg_eventstore/event.rb', line 18

attribute(:global_position)

#idString

Returns UUIDv4 string.

Returns:

  • (String)

    UUIDv4 string



12
# File 'lib/pg_eventstore/event.rb', line 12

attribute(:id)

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.

Returns:

  • (PgEventstore::Event, nil)

    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)

Returns UUIDv4 of an event the current event points to. If it is not nil, then the current event is a link.

Returns:

  • (String, nil)

    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)

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.

Returns:

  • (Integer, nil)

    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)

#metadataHash

Returns event’s metadata.

Returns:

  • (Hash)

    event’s metadata



30
# File 'lib/pg_eventstore/event.rb', line 30

attribute(:metadata) { {} }

#streamPgEventstore::Stream?

Returns event’s stream.

Returns:



21
# File 'lib/pg_eventstore/event.rb', line 21

attribute(:stream)

#stream_revisionInteger

Returns a revision of an event inside event’s stream.

Returns:

  • (Integer)

    a revision of an event inside event’s stream



24
# File 'lib/pg_eventstore/event.rb', line 24

attribute(:stream_revision)

#typeString

Returns event type.

Returns:

  • (String)

    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

Parameters:

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


64
65
66
# File 'lib/pg_eventstore/event.rb', line 64

def system?
  type.start_with?('$')
end