class ActionChannels::Message
Attributes
channel[RW]
details[RW]
type[RW]
Public Class Methods
new(attrs)
click to toggle source
# File lib/action_channels/message.rb, line 32 def initialize(attrs) @channel = attrs.fetch(:channel) @type = attrs.fetch(:type) @author = attrs[:author] @details = attrs.fetch :details, {} end
parse(message_raw)
click to toggle source
# 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
Public Instance Methods
systemic?()
click to toggle source
# File lib/action_channels/message.rb, line 43 def systemic? %w(subscribe unsubscribe).include? type end
to_raw()
click to toggle source
# File lib/action_channels/message.rb, line 39 def to_raw JSON.generate(channel: channel, type: type, details: details) end