aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-07-05 22:33:14 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-07-05 22:33:14 +0200
commit44e7cc324df1189531b60de1c6353289c8205a97 (patch)
treeefb49269584d3a3396da527d6811a4f22d173264 /lib/action_cable
parent417ff2a3e081cb92f4460e1a246433761dd4d964 (diff)
downloadrails-44e7cc324df1189531b60de1c6353289c8205a97.tar.gz
rails-44e7cc324df1189531b60de1c6353289c8205a97.tar.bz2
rails-44e7cc324df1189531b60de1c6353289c8205a97.zip
Extract connections methods into a separate concern
Diffstat (limited to 'lib/action_cable')
-rw-r--r--lib/action_cable/server.rb1
-rw-r--r--lib/action_cable/server/base.rb11
-rw-r--r--lib/action_cable/server/connections.rb21
3 files changed, 23 insertions, 10 deletions
diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb
index fa7bad4e32..a3d6ce6c31 100644
--- a/lib/action_cable/server.rb
+++ b/lib/action_cable/server.rb
@@ -2,6 +2,7 @@ module ActionCable
module Server
autoload :Base, 'action_cable/server/base'
autoload :Broadcasting, 'action_cable/server/broadcasting'
+ autoload :Connections, 'action_cable/server/connections'
autoload :Worker, 'action_cable/server/worker'
end
end
diff --git a/lib/action_cable/server/base.rb b/lib/action_cable/server/base.rb
index e8109b325d..fd3e5e4020 100644
--- a/lib/action_cable/server/base.rb
+++ b/lib/action_cable/server/base.rb
@@ -2,6 +2,7 @@ module ActionCable
module Server
class Base
include ActionCable::Server::Broadcasting
+ include ActionCable::Server::Connections
cattr_accessor(:logger, instance_reader: true) { Rails.logger }
@@ -51,16 +52,6 @@ module ActionCable
@connection_class.identifiers
end
- def add_connection(connection)
- @connections << connection
- end
-
- def remove_connection(connection)
- @connections.delete connection
- end
-
- def open_connections_statistics
- @connections.map(&:statistics)
end
end
end
diff --git a/lib/action_cable/server/connections.rb b/lib/action_cable/server/connections.rb
new file mode 100644
index 0000000000..4a3fa3c621
--- /dev/null
+++ b/lib/action_cable/server/connections.rb
@@ -0,0 +1,21 @@
+module ActionCable
+ module Server
+ module Connections
+ def connections
+ @connections ||= []
+ end
+
+ def add_connection(connection)
+ connections << connection
+ end
+
+ def remove_connection(connection)
+ connections.delete connection
+ end
+
+ def open_connections_statistics
+ connections.map(&:statistics)
+ end
+ end
+ end
+end \ No newline at end of file