From 44e7cc324df1189531b60de1c6353289c8205a97 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 5 Jul 2015 22:33:14 +0200 Subject: Extract connections methods into a separate concern --- lib/action_cable/server/base.rb | 11 +---------- lib/action_cable/server/connections.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 lib/action_cable/server/connections.rb (limited to 'lib/action_cable/server') 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 -- cgit v1.2.3