aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable/channel/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-07-07 21:30:51 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-07-07 21:30:51 +0200
commit6f4e9dea93ce306ea1badb839a723c2f4de91ccd (patch)
tree054d540ef283c37fce4e9512c0b3d8fd13cf8bcb /lib/action_cable/channel/base.rb
parent35ffec2c489bead9cc7f9c0525e9c63dc04e3038 (diff)
downloadrails-6f4e9dea93ce306ea1badb839a723c2f4de91ccd.tar.gz
rails-6f4e9dea93ce306ea1badb839a723c2f4de91ccd.tar.bz2
rails-6f4e9dea93ce306ea1badb839a723c2f4de91ccd.zip
No need for this delegator
Diffstat (limited to 'lib/action_cable/channel/base.rb')
-rw-r--r--lib/action_cable/channel/base.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb
index 2fcc82d039..f5d7011a72 100644
--- a/lib/action_cable/channel/base.rb
+++ b/lib/action_cable/channel/base.rb
@@ -59,9 +59,11 @@ module ActionCable
end
end
+ # Called by the cable connection when its cut so the channel has a chance to cleanup with callbacks.
+ # This method is not intended to be called directly by the user. Instead, overwrite the #unsubscribed callback.
def unsubscribe_from_channel
run_unsubscribe_callbacks
- logger.info "#{channel_name} unsubscribed"
+ logger.info "#{self.class.name} unsubscribed"
end
@@ -77,24 +79,18 @@ module ActionCable
def unsubscribed
# Override in subclasses
end
-
# Transmit a hash of data to the subscriber. The hash will automatically be wrapped in a JSON envelope with
# the proper channel identifier marked as the recipient.
def transmit(data, via: nil)
- logger.info "#{channel_name} transmitting #{data.inspect}".tap { |m| m << " (via #{via})" if via }
+ logger.info "#{self.class.name} transmitting #{data.inspect}".tap { |m| m << " (via #{via})" if via }
connection.transmit({ identifier: @identifier, message: data }.to_json)
end
- def channel_name
- self.class.name
- end
-
-
private
def subscribe_to_channel
- logger.info "#{channel_name} subscribing"
+ logger.info "#{self.class.name} subscribing"
run_subscribe_callbacks
end
@@ -107,7 +103,7 @@ module ActionCable
end
def action_signature(action, data)
- "#{channel_name}##{action}".tap do |signature|
+ "#{self.class.name}##{action}".tap do |signature|
if (arguments = data.except('action')).any?
signature << "(#{arguments.inspect})"
end