Class: Mayu::EventStream::Message

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mayu/event_stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event, data = {}) ⇒ Message

Returns a new instance of Message.



92
93
94
95
96
# File 'lib/mayu/event_stream.rb', line 92

def initialize(event, data = {})
  @id = T.let(Nanoid.generate, String)
  @event = T.let(event.to_s, String)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



89
90
91
# File 'lib/mayu/event_stream.rb', line 89

def data
  @data
end

#eventObject (readonly)

Returns the value of attribute event.



87
88
89
# File 'lib/mayu/event_stream.rb', line 87

def event
  @event
end

#idObject (readonly)

Returns the value of attribute id.



85
86
87
# File 'lib/mayu/event_stream.rb', line 85

def id
  @id
end

Instance Method Details

#to_aObject



99
100
101
# File 'lib/mayu/event_stream.rb', line 99

def to_a
  [@id, @event, @data]
end