Class: RocketChat::Realtime::Message
- Inherits:
-
Object
- Object
- RocketChat::Realtime::Message
- Defined in:
- lib/rocket_chat/realtime/message.rb
Overview
Abstract message model to send a method
Direct Known Subclasses
RocketChat::Realtime::Messages::Changed, RocketChat::Realtime::Messages::Method, RocketChat::Realtime::Messages::Result, RocketChat::Realtime::Messages::Subscribe
Instance Attribute Summary collapse
- #id ⇒ Object readonly
- #type ⇒ Object readonly
Instance Method Summary collapse
-
#body ⇒ Hash
Body.
-
#initialize(type = 'method', id = nil) ⇒ Message
constructor
A new instance of Message.
-
#to_json(options = nil) ⇒ String
Convert to JSON.
Constructor Details
#initialize(type = 'method', id = nil) ⇒ Message
Returns a new instance of Message.
18 19 20 21 |
# File 'lib/rocket_chat/realtime/message.rb', line 18 def initialize(type = 'method', id = nil) @id = id || SecureRandom.uuid @type = type end |
Instance Attribute Details
#id ⇒ Object (readonly)
12 13 14 |
# File 'lib/rocket_chat/realtime/message.rb', line 12 def id @id end |
#type ⇒ Object (readonly)
12 13 14 |
# File 'lib/rocket_chat/realtime/message.rb', line 12 def type @type end |
Instance Method Details
#body ⇒ Hash
Body
26 27 28 |
# File 'lib/rocket_chat/realtime/message.rb', line 26 def body {} end |
#to_json(options = nil) ⇒ String
Convert to JSON
33 34 35 36 37 |
# File 'lib/rocket_chat/realtime/message.rb', line 33 def to_json( = nil) body .merge(id: @id, msg: @type) .to_json() end |