Class: Wamp::Worker::Config
- Inherits:
-
Object
- Object
- Wamp::Worker::Config
- Defined in:
- lib/wamp/worker/config.rb
Overview
This class is used to store the configuration of the worker
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Returns the settings for a particular connection.
-
#connection(name = nil) ⇒ Object
Returns the connection options.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#redis(name = nil) ⇒ Object
Returns the redis value.
-
#registrations(name = nil) ⇒ Object
Returns the registrations.
-
#subscriptions(name = nil) ⇒ Object
Returns the subscriptions.
-
#timeout(name = nil) ⇒ Object
Returns the timeout value.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
120 121 122 |
# File 'lib/wamp/worker/config.rb', line 120 def initialize @settings = {} end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
118 119 120 |
# File 'lib/wamp/worker/config.rb', line 118 def settings @settings end |
Instance Method Details
#[](name) ⇒ Object
Returns the settings for a particular connection
176 177 178 179 180 |
# File 'lib/wamp/worker/config.rb', line 176 def [](name) settings = self.settings[name] || {} self.settings[name] = settings settings end |
#connection(name = nil) ⇒ Object
Returns the connection options
127 128 129 130 |
# File 'lib/wamp/worker/config.rb', line 127 def connection(name=nil) name ||= DEFAULT self[name][:connection] || {} end |
#redis(name = nil) ⇒ Object
Returns the redis value
143 144 145 146 147 148 149 150 151 152 153 154 155 |
# 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) ⇒ Object
Returns the registrations
168 169 170 171 |
# File 'lib/wamp/worker/config.rb', line 168 def registrations(name=nil) name ||= DEFAULT self[name][:registrations] || [] end |
#subscriptions(name = nil) ⇒ Object
Returns the subscriptions
160 161 162 163 |
# File 'lib/wamp/worker/config.rb', line 160 def subscriptions(name=nil) name ||= DEFAULT self[name][:subscriptions] || [] end |
#timeout(name = nil) ⇒ Object
Returns the timeout value
135 136 137 138 |
# File 'lib/wamp/worker/config.rb', line 135 def timeout(name=nil) name ||= DEFAULT self[name][:timeout] || 60 end |