aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable/connection
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-06-22 16:01:41 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-06-22 16:01:41 +0200
commit09974941ccc7f782d163197d1a96440fcc811e85 (patch)
tree89614add03871aa89969c3bbbb7550067b7973ef /lib/action_cable/connection
parentd796d9a61e1208f0706642ff02f7c8236185e55a (diff)
downloadrails-09974941ccc7f782d163197d1a96440fcc811e85.tar.gz
rails-09974941ccc7f782d163197d1a96440fcc811e85.tar.bz2
rails-09974941ccc7f782d163197d1a96440fcc811e85.zip
Extract helper method
Diffstat (limited to 'lib/action_cable/connection')
-rw-r--r--lib/action_cable/connection/base.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb
index c3c99dcec4..4bc6a14aaa 100644
--- a/lib/action_cable/connection/base.rb
+++ b/lib/action_cable/connection/base.rb
@@ -53,7 +53,7 @@ module ActionCable
def receive(data_in_json)
if websocket_alive?
- data = ActiveSupport::JSON.decode data_in_json
+ data = decode_json data_in_json
case data['command']
when 'subscribe' then subscriptions.add data
@@ -123,13 +123,17 @@ module ActionCable
def process_message(message)
- subscriptions.find(message['identifier']).perform_action(ActiveSupport::JSON.decode(message['data']))
+ subscriptions.find(message['identifier']).perform_action decode_json(message['data'])
rescue Exception => e
logger.error "Could not process message (#{message.inspect})"
log_exception(e)
end
+ def decode_json(json)
+ ActiveSupport::JSON.decode json
+ end
+
def respond_to_invalid_request
[ 404, { 'Content-Type' => 'text/plain' }, [ 'Page not found' ] ]
end