From acfdcf556888a88dc2d2026553d585f920fae105 Mon Sep 17 00:00:00 2001 From: Jeremy Daer Date: Fri, 16 Oct 2015 01:02:22 -0700 Subject: Devolve blanket #require to reveal intent and responsibility * Move specific requires close to where they're needed. * Use the private active_support/rails dep to wrap up common needs like eager autoload and module delegation. * Use a single Rails engine rather than an engine and a railtie. * Prefer `AS::JSON.encode` to `Object#to_json`. --- lib/action_cable/server/broadcasting.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/action_cable/server/broadcasting.rb') diff --git a/lib/action_cable/server/broadcasting.rb b/lib/action_cable/server/broadcasting.rb index 037b98951e..6e0fbae387 100644 --- a/lib/action_cable/server/broadcasting.rb +++ b/lib/action_cable/server/broadcasting.rb @@ -1,3 +1,5 @@ +require 'redis' + module ActionCable module Server # Broadcasting is how other parts of your application can send messages to the channel subscribers. As explained in Channel, most of the time, these @@ -44,9 +46,9 @@ module ActionCable def broadcast(message) server.logger.info "[ActionCable] Broadcasting to #{broadcasting}: #{message}" - server.broadcasting_redis.publish broadcasting, message.to_json + server.broadcasting_redis.publish broadcasting, ActiveSupport::JSON.encode(message) end end end end -end \ No newline at end of file +end -- cgit v1.2.3