class Wamp::Worker::ConfigProxy

This class is a config proxy that lets you specify the name globally

Attributes

config[R]
name[R]

Public Class Methods

new(config, name=nil) click to toggle source
# File lib/wamp/worker/config.rb, line 46
def initialize(config, name=nil)
  @name = name || DEFAULT
  @config = config
end

Public Instance Methods

[](attribute) click to toggle source

Gets the attribute using the name

@param attribute [Symbol] - The attribute

# File lib/wamp/worker/config.rb, line 110
def [](attribute)
  self.config[self.name][attribute]
end
[]=(attribute, value) click to toggle source

Sets the attribute using the name

@param attribute [Symbol] - The attribute @param value - The value for the attribute

# File lib/wamp/worker/config.rb, line 103
def []=(attribute, value)
  self.config[self.name][attribute] = value
end
configure(&callback) click to toggle source

Allows the user to configure without typing “config.”

# File lib/wamp/worker/config.rb, line 95
def configure(&callback)
  self.instance_eval(&callback)
end
connection(**options) click to toggle source

Connection options

# File lib/wamp/worker/config.rb, line 65
def connection(**options)
  self[:connection] = options
end
redis(connection) click to toggle source

Sets the Redis connection

# File lib/wamp/worker/config.rb, line 59
def redis(connection)
  self[:redis] = connection
end
register(procedure, klass, method, **options) click to toggle source

Register the handler for a procedure

@param procedure [String] - The procedure to register for @param klass [Wamp::Worker::Handler] - The class to use @param method [Symbol] - The name of the method to execute @param options [Hash] - Options for the subscription

# File lib/wamp/worker/config.rb, line 87
def register(procedure, klass, method, **options)
  registrations = self[:registrations] || []
  registrations << Registration.new(procedure, klass, method, options)
  self[:registrations] = registrations
end
subscribe(topic, klass, method, **options) click to toggle source

Subscribe the handler to a topic

@param topic [String] - The topic to subscribe to @param klass [Wamp::Worker::Handler] - The class to use @param method [Symbol] - The name of the method to execute @param options [Hash] - Options for the subscription

# File lib/wamp/worker/config.rb, line 75
def subscribe(topic, klass, method, **options)
  subscriptions = self[:subscriptions] || []
  subscriptions << Subscription.new(topic, klass, method, options)
  self[:subscriptions] = subscriptions
end
timeout(seconds) click to toggle source

Sets the timeout value

# File lib/wamp/worker/config.rb, line 53
def timeout(seconds)
  self[:timeout] = seconds
end