Class: PubSub::EventWithType
- Inherits:
-
RailsEventStore::Event
- Object
- RailsEventStore::Event
- PubSub::EventWithType
- Defined in:
- lib/pub_sub/event_with_type.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(event_id: SecureRandom.uuid, metadata: nil, data: {}) ⇒ EventWithType
constructor
A new instance of EventWithType.
- #stream_names ⇒ Object
Constructor Details
#initialize(event_id: SecureRandom.uuid, metadata: nil, data: {}) ⇒ EventWithType
Returns a new instance of EventWithType.
3 4 5 6 7 8 9 10 11 |
# File 'lib/pub_sub/event_with_type.rb', line 3 def initialize(event_id: SecureRandom.uuid, metadata: nil, data: {}) super( event_id:, metadata:, data: self.class.instance_variable_get(:@schema_validator).new( data.deep_symbolize_keys ).attributes ) end |
Class Method Details
.schema(&block) ⇒ Object
17 18 19 |
# File 'lib/pub_sub/event_with_type.rb', line 17 def self.schema(&block) instance_variable_set(:@schema_validator, Class.new(Dry::Struct, &block)) end |
Instance Method Details
#stream_names ⇒ Object
13 14 15 |
# File 'lib/pub_sub/event_with_type.rb', line 13 def stream_names [] end |