1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actioncable/lib/action_cable/server/configuration.rb

45 lines
1.5 KiB
Ruby
Raw Normal View History

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.
class Configuration
attr_accessor :logger, :log_tags
attr_accessor :connection_class, :worker_pool_size
attr_accessor :channels_path
attr_accessor :disable_request_forgery_protection, :allowed_request_origins
2016-01-15 17:26:17 -05:00
attr_accessor :cable, :url
def initialize
@log_tags = []
@connection_class = ApplicationCable::Connection
@worker_pool_size = 100
@channels_path = Rails.root.join('app/channels')
@disable_request_forgery_protection = false
end
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
# Returns constant of subscription adapter specified in config/cable.yml
# If the adapter cannot be found, this will default to the Redis adapter
def subscription_adapter
2016-01-07 09:37:41 -05:00
# Defaults to redis if no adapter is set
2016-01-15 17:26:17 -05:00
adapter = cable.fetch('adapter') { 'redis' }
adapter.camelize
adapter = 'PostgreSQL' if adapter == 'Postgresql'
"ActionCable::SubscriptionAdapter::#{adapter}".constantize
end
end
end
end