Class: Rage::Configuration::Cable

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCable

Returns a new instance of Cable.



282
283
284
285
286
287
# File 'lib/rage/configuration.rb', line 282

def initialize
  @protocol = Rage::Cable::Protocols::ActioncableV1Json
  @allowed_request_origins = if Rage.env.development? || Rage.env.test?
    /localhost/
  end
end

Instance Attribute Details

#allowed_request_originsObject

Returns the value of attribute allowed_request_origins.



279
280
281
# File 'lib/rage/configuration.rb', line 279

def allowed_request_origins
  @allowed_request_origins
end

#disable_request_forgery_protectionObject

Returns the value of attribute disable_request_forgery_protection.



279
280
281
# File 'lib/rage/configuration.rb', line 279

def disable_request_forgery_protection
  @disable_request_forgery_protection
end

#protocolObject

Returns the value of attribute protocol.



280
281
282
# File 'lib/rage/configuration.rb', line 280

def protocol
  @protocol
end

Instance Method Details

#adapterObject



334
335
336
337
338
339
# File 'lib/rage/configuration.rb', line 334

def adapter
  case config[:adapter]
  when "redis"
    Rage::Cable::Adapters::Redis.new(adapter_config)
  end
end

#adapter_configObject



330
331
332
# File 'lib/rage/configuration.rb', line 330

def adapter_config
  config.except(:adapter)
end

#configObject



317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/rage/configuration.rb', line 317

def config
  @config ||= begin
    config_file = Rage.root.join("config/cable.yml")

    if config_file.exist?
      yaml = ERB.new(config_file.read).result
      YAML.safe_load(yaml, aliases: true, symbolize_names: true)[Rage.env.to_sym] || {}
    else
      {}
    end
  end
end