aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-06-21 21:08:20 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-06-21 21:08:20 +0200
commit81ae9ee32162ececbd70664b2821e7c636eaed8b (patch)
tree3776838ed43fb8f52b2b7b8443f563f79dad6322 /lib
parentcc5ad6a65729a7c2c922e230c68b137762b8b127 (diff)
downloadrails-81ae9ee32162ececbd70664b2821e7c636eaed8b.tar.gz
rails-81ae9ee32162ececbd70664b2821e7c636eaed8b.tar.bz2
rails-81ae9ee32162ececbd70664b2821e7c636eaed8b.zip
Consolidate all identification logic in a single concern
Diffstat (limited to 'lib')
-rw-r--r--lib/action_cable/connection.rb2
-rw-r--r--lib/action_cable/connection/base.rb10
-rw-r--r--lib/action_cable/connection/identification.rb (renamed from lib/action_cable/connection/identifier.rb)15
-rw-r--r--lib/action_cable/connection/internal_channel.rb4
4 files changed, 19 insertions, 12 deletions
diff --git a/lib/action_cable/connection.rb b/lib/action_cable/connection.rb
index a9048926e4..8a695a3d0d 100644
--- a/lib/action_cable/connection.rb
+++ b/lib/action_cable/connection.rb
@@ -1,8 +1,8 @@
module ActionCable
module Connection
autoload :Base, 'action_cable/connection/base'
+ autoload :Identification, 'action_cable/connection/identification'
autoload :InternalChannel, 'action_cable/connection/internal_channel'
- autoload :Identifier, 'action_cable/connection/identifier'
autoload :TaggedLoggerProxy, 'action_cable/connection/tagged_logger_proxy'
end
end
diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb
index 4b73a90dc1..0d666713d2 100644
--- a/lib/action_cable/connection/base.rb
+++ b/lib/action_cable/connection/base.rb
@@ -1,17 +1,11 @@
module ActionCable
module Connection
class Base
- include InternalChannel, Identifier
+ include Identification
+ include InternalChannel
PING_INTERVAL = 3
- class_attribute :identifiers
- self.identifiers = Set.new
-
- def self.identified_by(*identifiers)
- self.identifiers += identifiers
- end
-
attr_reader :env, :server, :logger
delegate :worker_pool, :pubsub, to: :server
diff --git a/lib/action_cable/connection/identifier.rb b/lib/action_cable/connection/identification.rb
index 62524263bd..246636198b 100644
--- a/lib/action_cable/connection/identifier.rb
+++ b/lib/action_cable/connection/identification.rb
@@ -1,8 +1,17 @@
module ActionCable
module Connection
- module Identifier
- def internal_redis_channel
- "action_cable/#{connection_identifier}"
+ module Identification
+ extend ActiveSupport::Concern
+
+ included do
+ class_attribute :identifiers
+ self.identifiers = Set.new
+ end
+
+ class_methods do
+ def identified_by(*identifiers)
+ self.identifiers += identifiers
+ end
end
def connection_identifier
diff --git a/lib/action_cable/connection/internal_channel.rb b/lib/action_cable/connection/internal_channel.rb
index 3a11bcaf7b..55dfc72777 100644
--- a/lib/action_cable/connection/internal_channel.rb
+++ b/lib/action_cable/connection/internal_channel.rb
@@ -3,6 +3,10 @@ module ActionCable
module InternalChannel
extend ActiveSupport::Concern
+ def internal_redis_channel
+ "action_cable/#{connection_identifier}"
+ end
+
def subscribe_to_internal_channel
if connection_identifier.present?
callback = -> (message) { process_internal_message(message) }