1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Specify channel name as an attribute

This commit is contained in:
Pratik Naik 2015-01-15 23:49:01 +05:30
parent 843492ee6c
commit 792fe4b29c
2 changed files with 8 additions and 2 deletions

View file

@ -9,6 +9,8 @@ module ActionCable
attr_reader :params
class_attribute :channel_name
class << self
def matches?(identifier)
raise "Please implement #{name}#matches? method"

View file

@ -47,8 +47,12 @@ module ActionCable
id_key = data['identifier']
id_options = ActiveSupport::JSON.decode(id_key).with_indifferent_access
if subscription = registered_channels.detect { |channel_klass| channel_klass.matches?(id_options) }
@subscriptions[id_key] = subscription.new(self, id_key, id_options)
subscription_klass = registered_channels.detect do |channel_klass|
channel_klass.channel_name == id_options[:channel] && channel_klass.matches?(id_options)
end
if subscription_klass
@subscriptions[id_key] = subscription_klass.new(self, id_key, id_options)
@subscriptions[id_key].subscribe
else
# No channel found