diff options
Diffstat (limited to 'lib/action_cable')
-rw-r--r-- | lib/action_cable/channel/base.rb | 13 |
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? |