Privatize unneededly protected methods in Action Cable
This commit is contained in:
parent
102ee40557
commit
91fa2b71c3
@ -51,7 +51,7 @@ module ApplicationCable
|
||||
self.current_user = find_verified_user
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
def find_verified_user
|
||||
if current_user = User.find_by(id: cookies.signed[:user_id])
|
||||
current_user
|
||||
|
@ -122,16 +122,16 @@ def action_methods
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
# action_methods are cached and there is sometimes need to refresh
|
||||
# them. ::clear_action_methods! allows you to do that, so next time
|
||||
# you run action_methods, they will be recalculated.
|
||||
def clear_action_methods!
|
||||
def clear_action_methods! # :doc:
|
||||
@action_methods = nil
|
||||
end
|
||||
|
||||
# Refresh the cached action_methods when a new action_method is added.
|
||||
def method_added(name)
|
||||
def method_added(name) # :doc:
|
||||
super
|
||||
clear_action_methods!
|
||||
end
|
||||
@ -189,22 +189,22 @@ def unsubscribe_from_channel # :nodoc:
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
# Called once a consumer has become a subscriber of the channel. Usually the place to setup any streams
|
||||
# you want this channel to be sending to the subscriber.
|
||||
def subscribed
|
||||
def subscribed # :doc:
|
||||
# Override in subclasses
|
||||
end
|
||||
|
||||
# Called once a consumer has cut its cable connection. Can be used for cleaning up connections or marking
|
||||
# users as offline or the like.
|
||||
def unsubscribed
|
||||
def unsubscribed # :doc:
|
||||
# Override in subclasses
|
||||
end
|
||||
|
||||
# Transmit a hash of data to the subscriber. The hash will automatically be wrapped in a JSON envelope with
|
||||
# the proper channel identifier marked as the recipient.
|
||||
def transmit(data, via: nil)
|
||||
def transmit(data, via: nil) # :doc:
|
||||
logger.info "#{self.class.name} transmitting #{data.inspect.truncate(300)}".tap { |m| m << " (via #{via})" if via }
|
||||
|
||||
payload = { channel_class: self.class.name, data: data, via: via }
|
||||
@ -213,33 +213,32 @@ def transmit(data, via: nil)
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_confirmation_sent
|
||||
def ensure_confirmation_sent # :doc:
|
||||
return if subscription_rejected?
|
||||
@defer_subscription_confirmation_counter.decrement
|
||||
transmit_subscription_confirmation unless defer_subscription_confirmation?
|
||||
end
|
||||
|
||||
def defer_subscription_confirmation!
|
||||
def defer_subscription_confirmation! # :doc:
|
||||
@defer_subscription_confirmation_counter.increment
|
||||
end
|
||||
|
||||
def defer_subscription_confirmation?
|
||||
def defer_subscription_confirmation? # :doc:
|
||||
@defer_subscription_confirmation_counter.value > 0
|
||||
end
|
||||
|
||||
def subscription_confirmation_sent?
|
||||
def subscription_confirmation_sent? # :doc:
|
||||
@subscription_confirmation_sent
|
||||
end
|
||||
|
||||
def reject
|
||||
def reject # :doc:
|
||||
@reject_subscription = true
|
||||
end
|
||||
|
||||
def subscription_rejected?
|
||||
def subscription_rejected? # :doc:
|
||||
@reject_subscription
|
||||
end
|
||||
|
||||
private
|
||||
def delegate_connection_identifiers
|
||||
connection.identifiers.each do |identifier|
|
||||
define_singleton_method(identifier) do
|
||||
|
@ -22,7 +22,7 @@ module Connection
|
||||
# # Any cleanup work needed when the cable connection is cut.
|
||||
# end
|
||||
#
|
||||
# protected
|
||||
# private
|
||||
# def find_verified_user
|
||||
# User.find_by_identity(cookies.signed[:identity_id]) ||
|
||||
# reject_unauthorized_connection
|
||||
@ -136,8 +136,12 @@ def on_close(reason, code) # :nodoc:
|
||||
# TODO Change this to private once we've dropped Ruby 2.2 support.
|
||||
# Workaround for Ruby 2.2 "private attribute?" warning.
|
||||
protected
|
||||
attr_reader :websocket
|
||||
attr_reader :message_buffer
|
||||
|
||||
private
|
||||
# The request that initiated the WebSocket connection is available here. This gives access to the environment, cookies, etc.
|
||||
def request
|
||||
def request # :doc:
|
||||
@request ||= begin
|
||||
environment = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application
|
||||
ActionDispatch::Request.new(environment || env)
|
||||
@ -145,14 +149,10 @@ def request
|
||||
end
|
||||
|
||||
# The cookies of the request that initiated the WebSocket connection. Useful for performing authorization checks.
|
||||
def cookies
|
||||
def cookies # :doc:
|
||||
request.cookie_jar
|
||||
end
|
||||
|
||||
attr_reader :websocket
|
||||
attr_reader :message_buffer
|
||||
|
||||
private
|
||||
def encode(cable_message)
|
||||
@coder.encode cable_message
|
||||
end
|
||||
|
@ -31,8 +31,8 @@ def tag(logger)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def log(type, message)
|
||||
private
|
||||
def log(type, message) # :doc:
|
||||
tag(@logger) { @logger.send type, message }
|
||||
end
|
||||
end
|
||||
|
@ -23,7 +23,7 @@ def create_channel_file
|
||||
generate_application_cable_files
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
def file_name
|
||||
@_file_name ||= super.gsub(/_channel/i, "")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user