Class: PgEventstore::Stream
- Inherits:
-
Object
- Object
- PgEventstore::Stream
- Defined in:
- lib/pg_eventstore/stream.rb,
sig/pg_eventstore/stream.rbs
Constant Summary collapse
- NON_EXISTING_STREAM_REVISION =
-1 # @return [Array<String>]
- KNOWN_SYSTEM_STREAMS =
%w[].freeze
Instance Attribute Summary collapse
-
#context ⇒ String
Returns the value of attribute context.
-
#starting_position ⇒ Integer?
Returns the value of attribute starting_position.
-
#stream_id ⇒ String
Returns the value of attribute stream_id.
-
#stream_name ⇒ String
Returns the value of attribute stream_name.
-
#stream_revision ⇒ Integer?
Returns the value of attribute stream_revision.
Class Method Summary collapse
-
.all_stream ⇒ PgEventstore::Stream
Produces "all" stream instance.
- .system_stream ⇒ Stream
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #all_stream? ⇒ Boolean (also: #system?)
- #deconstruct ⇒ Array (also: #to_a)
- #deconstruct_keys(keys) ⇒ Hash<Symbol => String>
- #eql?(other) ⇒ Boolean
- #hash ⇒ Integer
-
#initialize(context:, stream_name:, stream_id:, stream_revision: nil, starting_position: nil) ⇒ Stream
constructor
A new instance of Stream.
- #to_hash ⇒ Hash
Constructor Details
#initialize(context:, stream_name:, stream_id:, stream_revision: nil, starting_position: nil) ⇒ Stream
Returns a new instance of Stream.
44 45 46 47 48 49 50 |
# File 'lib/pg_eventstore/stream.rb', line 44 def initialize(context:, stream_name:, stream_id:, stream_revision: nil, starting_position: nil) @context = context @stream_name = stream_name @stream_id = stream_id @stream_revision = stream_revision @starting_position = starting_position end |
Instance Attribute Details
#context ⇒ String
Returns the value of attribute context.
25 26 27 |
# File 'lib/pg_eventstore/stream.rb', line 25 def context @context end |
#starting_position ⇒ Integer?
Returns the value of attribute starting_position.
37 38 39 |
# File 'lib/pg_eventstore/stream.rb', line 37 def starting_position @starting_position end |
#stream_id ⇒ String
Returns the value of attribute stream_id.
31 32 33 |
# File 'lib/pg_eventstore/stream.rb', line 31 def stream_id @stream_id end |
#stream_name ⇒ String
Returns the value of attribute stream_name.
28 29 30 |
# File 'lib/pg_eventstore/stream.rb', line 28 def stream_name @stream_name end |
#stream_revision ⇒ Integer?
Returns the value of attribute stream_revision.
34 35 36 |
# File 'lib/pg_eventstore/stream.rb', line 34 def stream_revision @stream_revision end |
Class Method Details
.all_stream ⇒ PgEventstore::Stream
Produces "all" stream instance. "all" stream does not represent any specific stream. Instead, it indicates that a specific command should be performed over any kind of streams if possible
16 17 18 19 20 |
# File 'lib/pg_eventstore/stream.rb', line 16 def all_stream allocate.tap do |stream| stream.instance_variable_set(:@all_stream, true) end end |
.system_stream ⇒ Stream
8 |
# File 'sig/pg_eventstore/stream.rbs', line 8
def self.system_stream: (String) -> Stream
|
Instance Method Details
#==(other) ⇒ Boolean
93 94 95 96 97 |
# File 'lib/pg_eventstore/stream.rb', line 93 def ==(other) return false unless other.is_a?(Stream) to_hash == other.to_hash end |
#all_stream? ⇒ Boolean Also known as: system?
53 54 55 |
# File 'lib/pg_eventstore/stream.rb', line 53 def all_stream? !!@all_stream end |
#deconstruct ⇒ Array Also known as: to_a
59 60 61 |
# File 'lib/pg_eventstore/stream.rb', line 59 def deconstruct [context, stream_name, stream_id] end |
#deconstruct_keys(keys) ⇒ Hash<Symbol => String>
66 67 68 69 70 71 |
# File 'lib/pg_eventstore/stream.rb', line 66 def deconstruct_keys(keys) hash = { context:, stream_name:, stream_id: } return hash unless keys hash.slice(*keys) end |
#eql?(other) ⇒ Boolean
85 86 87 88 89 |
# File 'lib/pg_eventstore/stream.rb', line 85 def eql?(other) return false unless other.is_a?(Stream) hash == other.hash end |
#hash ⇒ Integer
79 80 81 |
# File 'lib/pg_eventstore/stream.rb', line 79 def hash to_hash.hash end |
#to_hash ⇒ Hash
74 75 76 |
# File 'lib/pg_eventstore/stream.rb', line 74 def to_hash deconstruct_keys(nil) end |