Method: ActionChannels::Message.parse

Defined in:
lib/action_channels/message.rb

.parse(message_raw) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/action_channels/message.rb', line 13

def parse(message_raw)
  command_json  = JSON.parse message_raw, symbolize_names: true

  new(
    channel: command_json[:channel],
    type: command_json[:type],
    details: command_json.fetch(:details, {})
  )
rescue JSON::ParserError => exp
  raise Errors::NotParseMessage, exp.message
end