class Wamp::Worker::Config

This class is used to store the configuration of the worker

Attributes

settings[R]

Public Class Methods

new() click to toggle source
# File lib/wamp/worker/config.rb, line 120
def initialize
  @settings = {}
end

Public Instance Methods

[](name) click to toggle source

Returns the settings for a particular connection

@param name [Symbol] - The name of the connection

# File lib/wamp/worker/config.rb, line 176
def [](name)
  settings = self.settings[name] || {}
  self.settings[name] = settings
  settings
end
connection(name=nil) click to toggle source

Returns the connection options

@param name [Symbol] - The name of the connection

# File lib/wamp/worker/config.rb, line 127
def connection(name=nil)
  name ||= DEFAULT
  self[name][:connection] || {}
end
redis(name=nil) click to toggle source

Returns the redis value

@param name [Symbol] - The name of the connection

# File lib/wamp/worker/config.rb, line 143
def redis(name=nil)
  name ||= DEFAULT
  redis = self[name][:redis]

  # If it is not a redis object, create one using it as the options
  if redis == nil
    redis = ::Redis.new
  elsif not redis.is_a? ::Redis
    redis = ::Redis.new(redis)
  end

  redis
end
registrations(name=nil) click to toggle source

Returns the registrations

@param name [Symbol] - The name of the connection

# File lib/wamp/worker/config.rb, line 168
def registrations(name=nil)
  name ||= DEFAULT
  self[name][:registrations] || []
end
subscriptions(name=nil) click to toggle source

Returns the subscriptions

@param name [Symbol] - The name of the connection

# File lib/wamp/worker/config.rb, line 160
def subscriptions(name=nil)
  name ||= DEFAULT
  self[name][:subscriptions] || []
end
timeout(name=nil) click to toggle source

Returns the timeout value

@param name [Symbol] - The name of the connection

# File lib/wamp/worker/config.rb, line 135
def timeout(name=nil)
  name ||= DEFAULT
  self[name][:timeout] || 60
end