Class: Concur::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/concur/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  init_defaults
  @listeners = []
  @max_threads = options[:max_threads] || defaults[:max_threads]
end

Instance Attribute Details

#defaultsObject (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_defaultsObject



11
12
13
14
15
# File 'lib/concur/config.rb', line 11

def init_defaults
  @defaults = {
      max_threads: 20
  }
end

#max_threadsObject



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