Class: ActionCable::Server::Configuration
- Inherits:
-
Object
- Object
- ActionCable::Server::Configuration
- Defined in:
- lib/action_cable/server/configuration.rb
Overview
An instance of this configuration object is available via ActionCable.server.config, which allows you to tweak Action Cable configuration in a Rails config initializer.
Instance Attribute Summary collapse
-
#allow_same_origin_as_host ⇒ Object
Returns the value of attribute allow_same_origin_as_host.
-
#allowed_request_origins ⇒ Object
Returns the value of attribute allowed_request_origins.
-
#cable ⇒ Object
Returns the value of attribute cable.
-
#connection_class ⇒ Object
Returns the value of attribute connection_class.
-
#disable_request_forgery_protection ⇒ Object
Returns the value of attribute disable_request_forgery_protection.
-
#log_tags ⇒ Object
Returns the value of attribute log_tags.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#mount_path ⇒ Object
Returns the value of attribute mount_path.
-
#url ⇒ Object
Returns the value of attribute url.
-
#use_faye ⇒ Object
Returns the value of attribute use_faye.
-
#worker_pool_size ⇒ Object
Returns the value of attribute worker_pool_size.
Instance Method Summary collapse
- #client_socket_class ⇒ Object
- #event_loop_class ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#pubsub_adapter ⇒ Object
Returns constant of subscription adapter specified in config/cable.yml.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 |
# File '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 |
Instance Attribute Details
#allow_same_origin_as_host ⇒ Object
Returns the value of attribute allow_same_origin_as_host.
8 9 10 |
# File 'lib/action_cable/server/configuration.rb', line 8 def allow_same_origin_as_host @allow_same_origin_as_host end |
#allowed_request_origins ⇒ Object
Returns the value of attribute allowed_request_origins.
8 9 10 |
# File 'lib/action_cable/server/configuration.rb', line 8 def allowed_request_origins @allowed_request_origins end |
#cable ⇒ Object
Returns the value of attribute cable.
9 10 11 |
# File 'lib/action_cable/server/configuration.rb', line 9 def cable @cable end |
#connection_class ⇒ Object
Returns the value of attribute connection_class.
7 8 9 |
# File 'lib/action_cable/server/configuration.rb', line 7 def connection_class @connection_class end |
#disable_request_forgery_protection ⇒ Object
Returns the value of attribute disable_request_forgery_protection.
8 9 10 |
# File 'lib/action_cable/server/configuration.rb', line 8 def disable_request_forgery_protection @disable_request_forgery_protection end |
#log_tags ⇒ Object
Returns the value of attribute log_tags.
6 7 8 |
# File 'lib/action_cable/server/configuration.rb', line 6 def @log_tags end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/action_cable/server/configuration.rb', line 6 def logger @logger end |
#mount_path ⇒ Object
Returns the value of attribute mount_path.
9 10 11 |
# File 'lib/action_cable/server/configuration.rb', line 9 def mount_path @mount_path end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/action_cable/server/configuration.rb', line 9 def url @url end |
#use_faye ⇒ Object
Returns the value of attribute use_faye.
7 8 9 |
# File 'lib/action_cable/server/configuration.rb', line 7 def use_faye @use_faye end |
#worker_pool_size ⇒ Object
Returns the value of attribute worker_pool_size.
7 8 9 |
# File 'lib/action_cable/server/configuration.rb', line 7 def worker_pool_size @worker_pool_size end |
Instance Method Details
#client_socket_class ⇒ Object
48 49 50 51 52 53 54 |
# File '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 ⇒ Object
40 41 42 43 44 45 46 |
# File '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 ⇒ Object
Returns constant of subscription adapter specified in config/cable.yml. If the adapter cannot be found, this will default to the Redis adapter. Also makes sure proper dependencies are required.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File '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 |