From 955bf93549f336d95862b12079f8b88f99145f8b Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 17 Jan 2015 11:39:28 +0530 Subject: Use underscored class name as the default channel name --- lib/action_cable/channel/base.rb | 4 ++++ lib/action_cable/server.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/action_cable') diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index 1ede07d9e3..6eaade4c8f 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -15,6 +15,10 @@ module ActionCable def matches?(identifier) raise "Please implement #{name}#matches? method" end + + def find_name + @name ||= channel_name || to_s.demodulize.underscore + end end def initialize(connection, channel_identifier, params = {}) diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index 08a6e9030b..eeeb50f08c 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -49,7 +49,7 @@ module ActionCable id_options = ActiveSupport::JSON.decode(id_key).with_indifferent_access subscription_klass = registered_channels.detect do |channel_klass| - channel_klass.channel_name == id_options[:channel] && channel_klass.matches?(id_options) + channel_klass.find_name == id_options[:channel] && channel_klass.matches?(id_options) end if subscription_klass -- cgit v1.2.3