Class: MongodbGraphite::InstanceList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mongodb-graphite/instance_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#merge_all

Constructor Details

#initialize(config) ⇒ InstanceList

Returns a new instance of InstanceList.



7
8
9
10
11
# File 'lib/mongodb-graphite/instance_list.rb', line 7

def initialize(config)
  @config = config
  @instances = {}
  reload
end

Instance Attribute Details

#instancesObject

Returns the value of attribute instances.



5
6
7
# File 'lib/mongodb-graphite/instance_list.rb', line 5

def instances
  @instances
end

Instance Method Details

#eachObject



39
40
41
42
43
# File 'lib/mongodb-graphite/instance_list.rb', line 39

def each
  @instances.each do |name,i|
    yield i
  end
end

#instance(name) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/mongodb-graphite/instance_list.rb', line 23

def instance(name)
  @options = {}
  yield
  @instances[name] ||= Instance.new(name)
  @instances[name].reload(@options)
  @options = nil
end

#reloadObject



13
14
15
16
17
18
19
20
21
# File 'lib/mongodb-graphite/instance_list.rb', line 13

def reload
  @instances = {}

  file = @config['instances_file']
  if not file.nil?
    #puts "Reading instance file from #{file}"
    instance_eval(File.read(file),file)
  end
end