aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable/channel/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-06-19 22:32:13 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-06-19 22:32:13 +0200
commit735e4d24a9d3674a3059b20260b808056aec6446 (patch)
tree78fefd73b4085e1cef3250ff31a21ab96e0ca9af /lib/action_cable/channel/base.rb
parenta44033e623f15524ce87235c79c9e547a54c8e69 (diff)
downloadrails-735e4d24a9d3674a3059b20260b808056aec6446.tar.gz
rails-735e4d24a9d3674a3059b20260b808056aec6446.tar.bz2
rails-735e4d24a9d3674a3059b20260b808056aec6446.zip
Add #perform_disconnection to have a place for both callbacks and logging
And using an unlikely-to-clash name.
Diffstat (limited to 'lib/action_cable/channel/base.rb')
-rw-r--r--lib/action_cable/channel/base.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb
index c18593bf6f..8580f9d75b 100644
--- a/lib/action_cable/channel/base.rb
+++ b/lib/action_cable/channel/base.rb
@@ -56,11 +56,9 @@ module ActionCable
send(callback)
end
end
-
- def run_unsubscribe_callbacks
- self.class.on_unsubscribe_callbacks.each do |callback|
- send(callback)
- end
+ def perform_disconnection
+ run_unsubscribe_callbacks
+ logger.info "#{self.class.name} disconnected"
end
protected
@@ -89,6 +87,11 @@ module ActionCable
end
end
+ private
+ def run_unsubscribe_callbacks
+ self.class.on_unsubscribe_callbacks.each { |callback| send(callback) }
+ end
+
def start_periodic_timers
self.class.periodic_timers.each do |callback, options|
@_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) do