Class: CableX::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- CableX::Engine
- Defined in:
- lib/cable_x/engine.rb
Overview
CableX Engine
Instance Attribute Summary collapse
-
#allowed_request_origins ⇒ Object
Returns the value of attribute allowed_request_origins.
Class Method Summary collapse
Instance Attribute Details
#allowed_request_origins ⇒ Object
Returns the value of attribute allowed_request_origins.
11 12 13 |
# File 'lib/cable_x/engine.rb', line 11 def allowed_request_origins @allowed_request_origins end |
Class Method Details
.server ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/cable_x/engine.rb', line 14 def self.server setup_rate_limiting server = CableX::Server.server server.config.connection_class = -> { CableX::Cable::Connection } server.config.allowed_request_origins = allowed_request_origins server end |
.setup_rate_limiting ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/cable_x/engine.rb', line 22 def self.setup_rate_limiting cable_config = Rails.application.config_for(:cable) rescue nil cable_x_config = Rails.application.config_for(:cable_x) rescue nil self.allowed_request_origins = cable_x_config[:allowed_request_origins] return unless cable_x_config && cable_config && cable_config[:adapter] == 'redis' CableX::Cable::Connection.redis_config = cable_config CableX::Cable::Connection.rate_limit = cable_x_config[:rate_limit] end |