Spec-Zone.ru › Ruby on Rails 5.0

класс ActionCable::Server::Configuration

Родитель:
Object

Экземпляр этого объекта конфигурации доступен через ActionCable.server.config, что позволяет настраивать Action Cable в файле конфигурации Rails.

Атрибуты

allow_same_origin_as_host[RW]
allowed_request_origins[RW]
cable[RW]
connection_class[RW]
disable_request_forgery_protection[RW]
log_tags[RW]
logger[RW]
mount_path[RW]
url[RW]
use_faye[RW]
worker_pool_size[RW]

Публичные методы класса

new() Показать исходный код
# File actioncable/lib/action_cable/server/configuration.rb, line 11
def initialize
  @log_tags = []

  @connection_class = -> { ActionCable::Connection::Base }
  @worker_pool_size = 4

  @disable_request_forgery_protection = false
  @allow_same_origin_as_host = true
end

Публичные методы экземпляра

client_socket_class() Показать исходный код
# File actioncable/lib/action_cable/server/configuration.rb, line 48
def client_socket_class
  if use_faye
    ActionCable::Connection::FayeClientSocket
  else
    ActionCable::Connection::ClientSocket
  end
end
event_loop_class() Показать исходный код
# File actioncable/lib/action_cable/server/configuration.rb, line 40
def event_loop_class
  if use_faye
    ActionCable::Connection::FayeEventLoop
  else
    ActionCable::Connection::StreamEventLoop
  end
end
pubsub_adapter() Показать исходный код
# File actioncable/lib/action_cable/server/configuration.rb, line 24
def pubsub_adapter
  adapter = (cable.fetch('adapter') { 'redis' })
  path_to_adapter = "action_cable/subscription_adapter/#{adapter}"
  begin
    require path_to_adapter
  rescue Gem::LoadError => e
    raise Gem::LoadError, "Specified '#{adapter}' for Action Cable pubsub adapter, but the gem is not loaded. Add `gem '#{e.name}'` to your Gemfile (and ensure its version is at the minimum required by Action Cable)."
  rescue LoadError => e
    raise LoadError, "Could not load '#{path_to_adapter}'. Make sure that the adapter in config/cable.yml is valid. If you use an adapter other than 'postgresql' or 'redis' add the necessary adapter gem to the Gemfile.", e.backtrace
  end

  adapter = adapter.camelize
  adapter = 'PostgreSQL' if adapter == 'Postgresql'
  "ActionCable::SubscriptionAdapter::#{adapter}".constantize
end

Возвращает константу адаптера подписки, указанного в файле config/cable.yml. Если адаптер не найден, по умолчанию используется адаптер Redis. Также проверяет наличие необходимых зависимостей.

© 2004–2018 David Heinemeier Hansson
Licensed under the MIT License.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API