class Wamp::Worker::ConfigProxy
This class is a config proxy that lets you specify the name globally
Attributes
Public Class Methods
# File lib/wamp/worker/config.rb, line 46 def initialize(config, name=nil) @name = name || DEFAULT @config = config end
Public Instance Methods
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
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
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
# File lib/wamp/worker/config.rb, line 65 def connection(**options) self[:connection] = options end
Sets the Redis connection
# File lib/wamp/worker/config.rb, line 59 def redis(connection) self[:redis] = connection end
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 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
Sets the timeout value
# File lib/wamp/worker/config.rb, line 53 def timeout(seconds) self[:timeout] = seconds end