lib/pubnub/events/channel_registration.rb in pubnub-4.0.27 vs lib/pubnub/events/channel_registration.rb in pubnub-4.0.28
- old
+ new
@@ -1,10 +1,10 @@
# Toplevel Pubnub module.
module Pubnub
# Holds channel_registration functionality
class ChannelRegistration < SingleEvent
- include Celluloid
+ include Concurrent::Async
include Pubnub::Validator::ChannelRegistration
def initialize(options, app)
@event = :channel_registration
@telemetry_name = :l_cg
@@ -14,44 +14,40 @@
private
def parameters(*_args)
parameters = super
- if @action == :add && !@channel.blank?
- parameters.merge!(add: Formatter.channels_for_url(@channel, false))
- end
+ parameters[:add] = Formatter.channels_for_url(@channel, false) if @action == :add && !@channel.blank?
- if @action == :remove && !@channel.blank?
- parameters.merge!(remove: Formatter.channels_for_url(@channel, false))
- end
+ parameters[:remove] = Formatter.channels_for_url(@channel, false) if @action == :remove && !@channel.blank?
parameters
end
def path
head = "/v1/channel-registration/sub-key/#{@subscribe_key}/"
body = case @action
- when :list_groups then
+ when :list_groups
body_list_groups
- when :list_namespaces then
+ when :list_namespaces
body_list_namespaces
- when :get then
+ when :get
body_get
- when :add then
+ when :add
body_add
- when :remove then
+ when :remove
body_remove
else
raise_action_key_error
end
head + body
end
def raise_action_key_error
- fail ArgumentError.new(
+ raise ArgumentError.new(
object: self,
message: 'ChannelRegistration requires proper :action key'
), 'ChannelRegistration requires proper :action key'
end
@@ -100,11 +96,11 @@
Pubnub::Envelope.new(
event: @event,
event_options: @given_options,
timetoken: nil,
status: {
- code: req_res_objects [:response].code,
+ code: req_res_objects[:response].code,
operation: define_operation,
client_request: req_res_objects[:request],
server_response: req_res_objects[:response],
data: nil,
category: Pubnub::Constants::STATUS_ACK,
@@ -116,10 +112,9 @@
subscribed_channels: nil,
subscribed_channel_groups: nil,
config: get_config
},
-
result: {
data: parsed_response['payload'],
code: req_res_objects[:response].code,
operation: define_operation,
client_request: req_res_objects[:request],