lib/slack/real_time/client.rb in slack-ruby-client-0.10.0 vs lib/slack/real_time/client.rb in slack-ruby-client-0.11.0
- old
+ new
@@ -31,11 +31,11 @@
@token ||= Slack.config.token
@logger ||= (Slack::Config.logger || Slack::Logger.default)
@web_client = Slack::Web::Client.new(token: token, logger: logger)
end
- [:users, :self, :channels, :team, :teams, :groups, :ims, :bots].each do |store_method|
+ %i[users self channels team teams groups ims bots].each do |store_method|
define_method store_method do
store.send(store_method) if store
end
end
@@ -58,11 +58,11 @@
@socket = build_socket
@socket.start_async(self)
end
def stop!
- fail ClientNotStartedError unless started?
+ raise ClientNotStartedError unless started?
@socket.disconnect! if @socket
end
def started?
@socket && @socket.connected?
@@ -104,11 +104,11 @@
protected
# @return [Slack::RealTime::Socket]
def build_socket
- fail ClientAlreadyStartedError if started?
+ raise ClientAlreadyStartedError if started?
start = web_client.send(rtm_start_method, start_options)
data = Slack::Messages::Message.new(start)
@url = data.url
@store = @store_class.new(data) if @store_class
socket_class.new(@url, socket_options)
@@ -136,17 +136,16 @@
def socket_class
concurrency::Socket
end
def send_json(data)
- fail ClientNotStartedError unless started?
+ raise ClientNotStartedError unless started?
logger.debug("#{self.class}##{__method__}") { data }
@socket.send_data(data.to_json)
end
- def open(_event)
- end
+ def open(_event); end
def close(_event)
socket = @socket
@socket = nil
@@ -181,12 +180,14 @@
false
end
def run_handlers(type, data)
handlers = store.class.events[type.to_s]
- handlers.each do |handler|
- store.instance_exec(data, &handler)
- end if handlers
+ if handlers
+ handlers.each do |handler|
+ store.instance_exec(data, &handler)
+ end
+ end
rescue StandardError => e
logger.error e
false
end