Class: Megaphone::Client::Event
- Inherits:
-
Object
- Object
- Megaphone::Client::Event
- Defined in:
- lib/megaphone/client/event.rb
Instance Method Summary collapse
-
#initialize(topic, subtopic, origin, schema, partition_key, payload) ⇒ Event
constructor
A new instance of Event.
- #stream_id ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(topic, subtopic, origin, schema, partition_key, payload) ⇒ Event
Returns a new instance of Event.
6 7 8 9 10 11 12 13 |
# File 'lib/megaphone/client/event.rb', line 6 def initialize(topic, subtopic, origin, schema, partition_key, payload) @topic = topic @subtopic = subtopic @origin = origin @schema = schema @partition_key = partition_key @payload = payload end |
Instance Method Details
#stream_id ⇒ Object
15 16 17 |
# File 'lib/megaphone/client/event.rb', line 15 def stream_id "#{@topic}.#{@subtopic}" end |
#to_hash ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/megaphone/client/event.rb', line 19 def to_hash { schema: @schema, origin: @origin, topic: @topic, subtopic: @subtopic, partitionKey: @partition_key, data: @payload } end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/megaphone/client/event.rb', line 30 def to_s JSON.dump(to_hash) end |