Class: MicroQ::Config
- Inherits:
-
Object
- Object
- MicroQ::Config
- Defined in:
- lib/micro_q/config.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ Config
constructor
Configuration accessible via: 1.
- #method_missing(method, *args) ⇒ Object
- #queue=(q) ⇒ Object
Constructor Details
#initialize ⇒ Config
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/micro_q/config.rb', line 11 def initialize @data = { 'workers' => 5, 'timeout' => 120, 'interval' => 5, 'env' => defined?(Rails) ? Rails.env : 'development', 'middleware' => Middleware::Chain.new, 'manager' => Manager::Default, 'worker' => Worker::Standard, 'queue' => Queue::Default, 'statistics' => Statistics::Default, 'aws' => {}, 'redis_pool' => { :size => 15, :timeout => 1 }, 'redis' => { :host => 'localhost', :port => 6379 } } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/micro_q/config.rb', line 48 def method_missing(method, *args) case method when /(.+)=$/ then @data[$1] = args.first else @data[method.to_s] end end |
Instance Method Details
#[](key) ⇒ Object
32 33 34 |
# File 'lib/micro_q/config.rb', line 32 def [](key) @data[key.to_s] end |
#[]=(key, value) ⇒ Object
28 29 30 |
# File 'lib/micro_q/config.rb', line 28 def []=(key, value) @data[key.to_s] = value end |