Class: ActionCable::Server::Configuration

Inherits:
Object
  • Object
show all
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 the configuration points in a Rails config initializer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.


10
11
12
13
14
15
16
17
18
19
# File 'lib/action_cable/server/configuration.rb', line 10

def initialize
  @logger   = Rails.logger
  @log_tags = []

  @connection_class  = ApplicationCable::Connection
  @worker_pool_size  = 100

  @redis_path    = Rails.root.join('config/redis/cable.yml')
  @channels_path = Rails.root.join('app/channels')
end

Instance Attribute Details

#channels_pathObject

Returns the value of attribute channels_path


8
9
10
# File 'lib/action_cable/server/configuration.rb', line 8

def channels_path
  @channels_path
end

#connection_classObject

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

#log_tagsObject

Returns the value of attribute log_tags


6
7
8
# File 'lib/action_cable/server/configuration.rb', line 6

def log_tags
  @log_tags
end

#loggerObject

Returns the value of attribute logger


6
7
8
# File 'lib/action_cable/server/configuration.rb', line 6

def logger
  @logger
end

#redis_pathObject

Returns the value of attribute redis_path


8
9
10
# File 'lib/action_cable/server/configuration.rb', line 8

def redis_path
  @redis_path
end

#worker_pool_sizeObject

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

#channel_class_namesObject


25
26
27
28
29
# File 'lib/action_cable/server/configuration.rb', line 25

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

#channel_pathsObject


21
22
23
# File 'lib/action_cable/server/configuration.rb', line 21

def channel_paths
  @channels ||= Dir["#{channels_path}/**/*_channel.rb"]
end

#redisObject


31
32
33
# File 'lib/action_cable/server/configuration.rb', line 31

def redis
  @redis ||= config_for(redis_path).with_indifferent_access
end