diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-07-30 20:37:30 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-07-30 20:37:30 +0200 |
commit | 219c48e18b10bebbefb1c12d94278f3e0d94a0b5 (patch) | |
tree | d206c39719f734992f36abf994eaca962357f395 /lib/action_cable/connection | |
parent | 0c30d87868a8b59c47acbc695ef5e37d6361b3cc (diff) | |
parent | 8544df97f7a77401292fb6fa5a07087f47764f33 (diff) | |
download | rails-219c48e18b10bebbefb1c12d94278f3e0d94a0b5.tar.gz rails-219c48e18b10bebbefb1c12d94278f3e0d94a0b5.tar.bz2 rails-219c48e18b10bebbefb1c12d94278f3e0d94a0b5.zip |
Merge pull request #48 from jasondew/documentation_and_whitespace_fixes
Fixing documentation, correcting grammar, and removing unnecessary whitespace
Diffstat (limited to 'lib/action_cable/connection')
-rw-r--r-- | lib/action_cable/connection/base.rb | 12 | ||||
-rw-r--r-- | lib/action_cable/connection/heartbeat.rb | 6 | ||||
-rw-r--r-- | lib/action_cable/connection/identification.rb | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb index 5671dc1f88..08a75156a3 100644 --- a/lib/action_cable/connection/base.rb +++ b/lib/action_cable/connection/base.rb @@ -12,7 +12,7 @@ module ActionCable # module ApplicationCable # class Connection < ActionCable::Connection::Base # identified_by :current_user - # + # # def connect # self.current_user = find_verified_user # logger.add_tags current_user.name @@ -21,7 +21,7 @@ module ActionCable # def disconnect # # Any cleanup work needed when the cable connection is cut. # end - # + # # protected # def find_verified_user # if current_user = User.find_by_identity cookies.signed[:identity_id] @@ -37,7 +37,7 @@ module ActionCable # established for that current_user (and potentially disconnect them if the user was removed from an account). You can declare as many # identification indexes as you like. Declaring an identification means that a attr_accessor is automatically set for that key. # - # Second, we rely on the fact that the websocket connection is established with the cookies from that domain being sent along. This makes + # Second, we rely on the fact that the websocket connection is established with the cookies from the domain being sent along. This makes # it easy to use signed cookies that were set when logging in via a web interface to authorize the websocket connection. # # Finally, we add a tag to the connection-specific logger with name of the current user to easily distinguish their messages in the log. @@ -75,14 +75,14 @@ module ActionCable websocket.on(:open) { |event| send_async :on_open } websocket.on(:message) { |event| on_message event.data } websocket.on(:close) { |event| send_async :on_close } - + respond_to_successful_request else respond_to_invalid_request end end - # Data received over the cable is handled by this method. It's expected that everything inbound is encoded with JSON. + # Data received over the cable is handled by this method. It's expected that everything inbound is JSON encoded. # The data is routed to the proper channel that the connection has subscribed to. def receive(data_in_json) if websocket.alive? @@ -177,7 +177,7 @@ module ActionCable # Tags are declared in the server but computed in the connection. This allows us per-connection tailored tags. def new_tagged_logger - TaggedLoggerProxy.new server.logger, + TaggedLoggerProxy.new server.logger, tags: server.config.log_tags.map { |tag| tag.respond_to?(:call) ? tag.call(request) : tag.to_s.camelize } end diff --git a/lib/action_cable/connection/heartbeat.rb b/lib/action_cable/connection/heartbeat.rb index e0f4a97f53..2918938ba5 100644 --- a/lib/action_cable/connection/heartbeat.rb +++ b/lib/action_cable/connection/heartbeat.rb @@ -5,7 +5,7 @@ module ActionCable # disconnect. class Heartbeat BEAT_INTERVAL = 3 - + def initialize(connection) @connection = connection end @@ -21,10 +21,10 @@ module ActionCable private attr_reader :connection - + def beat connection.transmit({ identifier: '_ping', message: Time.now.to_i }.to_json) end end end -end
\ No newline at end of file +end diff --git a/lib/action_cable/connection/identification.rb b/lib/action_cable/connection/identification.rb index 113e41ca3f..1be6f9ac76 100644 --- a/lib/action_cable/connection/identification.rb +++ b/lib/action_cable/connection/identification.rb @@ -16,7 +16,7 @@ module ActionCable # channel instances created off the connection. def identified_by(*identifiers) Array(identifiers).each { |identifier| attr_accessor identifier } - self.identifiers += identifiers + self.identifiers += identifiers end end |