Class: PgEventstore::Event

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

Constant Summary collapse

'$>'
PRIMARY_TABLE_NAME =

Returns:

  • (String)
'events'

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



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

attribute(:created_at)

#dataHash

Returns event’s data.

Returns:

  • (Hash)

    event’s data



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

attribute(:data) { {} }

#global_positionInteger

Returns event’s position in “all” stream.

Returns:

  • (Integer)

    event’s position in “all” stream



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

attribute(:global_position)

#idString

Returns UUIDv4 string.

Returns:

  • (String)

    UUIDv4 string



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

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



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

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



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

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.



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

attribute(:link_partition_id)

#metadataHash

Returns event’s metadata.

Returns:

  • (Hash)

    event’s metadata



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

attribute(:metadata) { {} }

#streamPgEventstore::Stream?

Returns event’s stream.

Returns:



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

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



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

attribute(:stream_revision)

#typeString

Returns event type.

Returns:

  • (String)

    event type



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

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)


52
53
54
55
56
# File 'lib/pg_eventstore/event.rb', line 52

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)


60
61
62
# File 'lib/pg_eventstore/event.rb', line 60

def link?
  !link_id.nil?
end

#system?Boolean

Detect whether an event is a system event

Returns:

  • (Boolean)


66
67
68
# File 'lib/pg_eventstore/event.rb', line 66

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