aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable/server
diff options
context:
space:
mode:
authorLachlan Sylvester <lachlan.sylvester@publicisfrontfoot.com.au>2015-07-28 15:13:07 +1000
committerLachlan Sylvester <lachlan.sylvester@publicisfrontfoot.com.au>2015-07-30 10:14:57 +1000
commit60e2fa5e955ce819c90f2081320554b5ed0ee83c (patch)
treefa0c24e3149a06116079c392f3cea3c3928b05de /lib/action_cable/server
parent65fde3bf75cf82bf18d8cfa36bc07f52c9a866ff (diff)
downloadrails-60e2fa5e955ce819c90f2081320554b5ed0ee83c.tar.gz
rails-60e2fa5e955ce819c90f2081320554b5ed0ee83c.tar.bz2
rails-60e2fa5e955ce819c90f2081320554b5ed0ee83c.zip
refactor channel look up to use a hash instead of an array and reduce the number of calls to safe_constantize because it can be slow
Diffstat (limited to 'lib/action_cable/server')
-rw-r--r--lib/action_cable/server/base.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/action_cable/server/base.rb b/lib/action_cable/server/base.rb
index b09fbf6da4..43849928b9 100644
--- a/lib/action_cable/server/base.rb
+++ b/lib/action_cable/server/base.rb
@@ -36,11 +36,11 @@ module ActionCable
@worker_pool ||= ActionCable::Server::Worker.pool(size: config.worker_pool_size)
end
- # Requires and returns an array of all the channel class constants in this application.
+ # Requires and returns an hash of all the channel class constants keyed by name.
def channel_classes
@channel_classes ||= begin
config.channel_paths.each { |channel_path| require channel_path }
- config.channel_class_names.collect { |name| name.constantize }
+ config.channel_class_names.each_with_object({}) { |name, hash| hash[name] = name.constantize }
end
end