Class: Message

Inherits:
Object
  • Object
show all
Defined in:
lib/backchannel/message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_idObject (readonly)

Returns the value of attribute client_id.



4
5
6
# File 'lib/backchannel/message.rb', line 4

def client_id
  @client_id
end

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/backchannel/message.rb', line 4

def content
  @content
end

#handleObject (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_jsonObject



17
18
19
# File 'lib/backchannel/message.rb', line 17

def to_json
  { client_id: client_id, handle: handle, content: content }.to_json
end