Class: Message
- Inherits:
-
Object
- Object
- Message
- Defined in:
- lib/backchannel/message.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Message
constructor
A new instance of Message.
- #to_json ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Message
Returns a new instance of Message.
11 12 13 14 15 |
# File 'lib/backchannel/message.rb', line 11 def initialize(attributes={}) @client_id = attributes.fetch("client_id") @handle = attributes.fetch("handle") @content = attributes.fetch("content") end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
4 5 6 |
# File 'lib/backchannel/message.rb', line 4 def client_id @client_id end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/backchannel/message.rb', line 4 def content @content end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
4 5 6 |
# File 'lib/backchannel/message.rb', line 4 def handle @handle end |
Class Method Details
.inflate(json) ⇒ Object
6 7 8 9 |
# File 'lib/backchannel/message.rb', line 6 def self.inflate(json) attributes = JSON.parse(json) new(attributes) end |
Instance Method Details
#to_json ⇒ Object
17 18 19 |
# File 'lib/backchannel/message.rb', line 17 def to_json { client_id: client_id, handle: handle, content: content }.to_json end |