aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-07-07 21:39:16 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-07-07 21:39:16 +0200
commit74d764b120fad7fd21781b3c2df4abfac5518e78 (patch)
treece1555f3c6fa976da842a6de87e72c871d8a1ae1
parent6f4e9dea93ce306ea1badb839a723c2f4de91ccd (diff)
downloadrails-74d764b120fad7fd21781b3c2df4abfac5518e78.tar.gz
rails-74d764b120fad7fd21781b3c2df4abfac5518e78.tar.bz2
rails-74d764b120fad7fd21781b3c2df4abfac5518e78.zip
Allow actions not to accept the data argument
-rw-r--r--lib/action_cable/channel/base.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb
index f5d7011a72..fb29ba1893 100644
--- a/lib/action_cable/channel/base.rb
+++ b/lib/action_cable/channel/base.rb
@@ -52,8 +52,7 @@ module ActionCable
action = extract_action(data)
if processable_action?(action)
- logger.info action_signature(action, data)
- public_send action, data
+ dispatch_action(action, data)
else
logger.error "Unable to process #{action_signature(action, data)}"
end
@@ -102,6 +101,16 @@ module ActionCable
self.class.instance_methods(false).include?(action)
end
+ def dispatch_action(action, data)
+ logger.info action_signature(action, data)
+
+ if method(action).arity == 1
+ public_send action, data
+ else
+ public_send action
+ end
+ end
+
def action_signature(action, data)
"#{self.class.name}##{action}".tap do |signature|
if (arguments = data.except('action')).any?