Class: Yes::Core::Commands::Stateless::Subject
- Inherits:
-
Data
- Object
- Data
- Yes::Core::Commands::Stateless::Subject
- Defined in:
- lib/yes/core/commands/stateless/subject.rb
Overview
Subject object is responsible for holding subject data
Constant Summary collapse
- OPTIONAL_FIELDS =
%i[stream_prefix].index_with(nil).freeze
Instance Attribute Summary collapse
-
#aggregate_id ⇒ String
readonly
The current value of aggregate_id.
-
#context ⇒ String
readonly
The current value of context.
-
#stream_prefix ⇒ String
readonly
value is optional.
-
#subject ⇒ String
readonly
The current value of subject.
Instance Method Summary collapse
- #computed_stream_prefix ⇒ String
-
#initialize(**attrs) ⇒ Subject
constructor
A new instance of Subject.
- #stream ⇒ PgEventstore::Stream
Constructor Details
#initialize(**attrs) ⇒ Subject
Returns a new instance of Subject.
23 24 25 |
# File 'lib/yes/core/commands/stateless/subject.rb', line 23 def initialize(**attrs) super(**OPTIONAL_FIELDS.merge(attrs)) end |
Instance Attribute Details
#aggregate_id ⇒ String (readonly)
Returns the current value of aggregate_id.
20 21 22 |
# File 'lib/yes/core/commands/stateless/subject.rb', line 20 def aggregate_id @aggregate_id end |
#context ⇒ String (readonly)
Returns the current value of context.
20 21 22 |
# File 'lib/yes/core/commands/stateless/subject.rb', line 20 def context @context end |
#stream_prefix ⇒ String (readonly)
value is optional
20 21 22 |
# File 'lib/yes/core/commands/stateless/subject.rb', line 20 def stream_prefix @stream_prefix end |
#subject ⇒ String (readonly)
Returns the current value of subject.
20 21 22 |
# File 'lib/yes/core/commands/stateless/subject.rb', line 20 def subject @subject end |
Instance Method Details
#computed_stream_prefix ⇒ String
34 35 36 |
# File 'lib/yes/core/commands/stateless/subject.rb', line 34 def computed_stream_prefix stream_prefix || "#{context}::#{subject}" end |
#stream ⇒ PgEventstore::Stream
28 29 30 31 |
# File 'lib/yes/core/commands/stateless/subject.rb', line 28 def stream parts = computed_stream_prefix.split('::') PgEventstore::Stream.new(context: parts[0], stream_name: parts[1..].join('::'), stream_id: aggregate_id) end |