From 661298176c72eefc6d0f42b58210119e76962364 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Fri, 5 Feb 2016 22:48:48 +0100 Subject: Inject Rails' channel paths in engine. We were explicitly referencing Rails.root in ActionCable::Server::Configuration.initialize, thereby coupling ourselves to Rails. Instead add `app/channels` to Rails' app paths and assign the existent files to `channel_paths`. Users can still append to those load paths with `<<` and `push` in `config/application.rb`. This means we can remove the custom `Dir` lookup in `channel_paths` and the Rails and root definitions in the tests. --- actioncable/lib/action_cable/server/configuration.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'actioncable/lib/action_cable/server/configuration.rb') diff --git a/actioncable/lib/action_cable/server/configuration.rb b/actioncable/lib/action_cable/server/configuration.rb index 9a248933c4..019a374734 100644 --- a/actioncable/lib/action_cable/server/configuration.rb +++ b/actioncable/lib/action_cable/server/configuration.rb @@ -5,27 +5,20 @@ module ActionCable class Configuration attr_accessor :logger, :log_tags attr_accessor :connection_class, :worker_pool_size - attr_accessor :channel_load_paths attr_accessor :disable_request_forgery_protection, :allowed_request_origins attr_accessor :cable, :url + attr_accessor :channel_paths # :nodoc: + def initialize @log_tags = [] @connection_class = ApplicationCable::Connection @worker_pool_size = 100 - @channel_load_paths = [Rails.root.join('app/channels')] - @disable_request_forgery_protection = false end - def channel_paths - @channel_paths ||= channel_load_paths.flat_map do |path| - Dir["#{path}/**/*_channel.rb"] - end - end - def channel_class_names @channel_class_names ||= channel_paths.collect do |channel_path| Pathname.new(channel_path).basename.to_s.split('.').first.camelize -- cgit v1.2.3 From 861ece99bb6d7ebdb27fad7db5ccc05340aaf0e5 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Fri, 5 Feb 2016 22:56:52 +0100 Subject: Default connection class to ActionCable::Connection::Base. Instead of depending on ApplicationCable::Connection being defined at initialize we should inject it in the Railtie. Thus we can kill more setup in the tests too. --- actioncable/lib/action_cable/server/configuration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actioncable/lib/action_cable/server/configuration.rb') diff --git a/actioncable/lib/action_cable/server/configuration.rb b/actioncable/lib/action_cable/server/configuration.rb index 019a374734..58bb8ff65a 100644 --- a/actioncable/lib/action_cable/server/configuration.rb +++ b/actioncable/lib/action_cable/server/configuration.rb @@ -13,8 +13,8 @@ module ActionCable def initialize @log_tags = [] - @connection_class = ApplicationCable::Connection - @worker_pool_size = 100 + @connection_class = ActionCable::Connection::Base + @worker_pool_size = 100 @disable_request_forgery_protection = false end -- cgit v1.2.3