Class: Concur::Config
- Inherits:
-
Object
- Object
- Concur::Config
- Defined in:
- lib/concur/config.rb
Instance Attribute Summary collapse
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
Instance Method Summary collapse
- #add_listener(l) ⇒ Object
- #init_defaults ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #max_threads ⇒ Object
- #max_threads=(x) ⇒ Object
- #notify_listeners(changes) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 |
# File 'lib/concur/config.rb', line 5 def initialize(={}) init_defaults @listeners = [] @max_threads = [:max_threads] || defaults[:max_threads] end |
Instance Attribute Details
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
3 4 5 |
# File 'lib/concur/config.rb', line 3 def defaults @defaults end |
Instance Method Details
#add_listener(l) ⇒ Object
26 27 28 |
# File 'lib/concur/config.rb', line 26 def add_listener(l) @listeners << l end |
#init_defaults ⇒ Object
11 12 13 14 15 |
# File 'lib/concur/config.rb', line 11 def init_defaults @defaults = { max_threads: 20 } end |
#max_threads ⇒ Object
22 23 24 |
# File 'lib/concur/config.rb', line 22 def max_threads @max_threads end |
#max_threads=(x) ⇒ Object
17 18 19 20 |
# File 'lib/concur/config.rb', line 17 def max_threads=(x) @max_threads = x notify_listeners(:max_threads=>x) end |
#notify_listeners(changes) ⇒ Object
30 31 32 33 34 |
# File 'lib/concur/config.rb', line 30 def notify_listeners(changes) @listeners.each do |l| l.update(changes) end end |