2015-10-16 04:02:22 -04:00
|
|
|
require 'active_support/core_ext/hash/indifferent_access'
|
|
|
|
|
2015-07-05 16:34:23 -04:00
|
|
|
module ActionCable
|
|
|
|
module Server
|
2015-07-07 17:13:00 -04:00
|
|
|
# An instance of this configuration object is available via ActionCable.server.config, which allows you to tweak the configuration points
|
|
|
|
# in a Rails config initializer.
|
2015-07-05 16:34:23 -04:00
|
|
|
class Configuration
|
|
|
|
attr_accessor :logger, :log_tags
|
|
|
|
attr_accessor :connection_class, :worker_pool_size
|
2015-12-15 12:59:00 -05:00
|
|
|
attr_accessor :redis, :channels_path
|
2015-10-07 12:24:20 -04:00
|
|
|
attr_accessor :disable_request_forgery_protection, :allowed_request_origins
|
2015-09-03 20:17:48 -04:00
|
|
|
attr_accessor :url
|
2015-07-05 16:34:23 -04:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
@logger = Rails.logger
|
|
|
|
@log_tags = []
|
|
|
|
|
|
|
|
@connection_class = ApplicationCable::Connection
|
|
|
|
@worker_pool_size = 100
|
|
|
|
|
|
|
|
@channels_path = Rails.root.join('app/channels')
|
2015-10-07 12:24:20 -04:00
|
|
|
|
|
|
|
@disable_request_forgery_protection = false
|
2015-07-05 16:34:23 -04:00
|
|
|
end
|
|
|
|
|
2015-08-07 04:58:22 -04:00
|
|
|
def log_to_stdout
|
|
|
|
console = ActiveSupport::Logger.new($stdout)
|
|
|
|
console.formatter = @logger.formatter
|
|
|
|
console.level = @logger.level
|
|
|
|
|
|
|
|
@logger.extend(ActiveSupport::Logger.broadcast(console))
|
|
|
|
end
|
|
|
|
|
2015-07-05 16:34:23 -04:00
|
|
|
def channel_paths
|
|
|
|
@channels ||= Dir["#{channels_path}/**/*_channel.rb"]
|
|
|
|
end
|
|
|
|
|
|
|
|
def channel_class_names
|
|
|
|
@channel_class_names ||= channel_paths.collect do |channel_path|
|
|
|
|
Pathname.new(channel_path).basename.to_s.split('.').first.camelize
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|