Class: MongodbGraphite::InstanceList
- Inherits:
-
Object
- Object
- MongodbGraphite::InstanceList
- Includes:
- Enumerable
- Defined in:
- lib/mongodb-graphite/instance_list.rb
Instance Attribute Summary collapse
-
#instances ⇒ Object
Returns the value of attribute instances.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(config) ⇒ InstanceList
constructor
A new instance of InstanceList.
- #instance(name) ⇒ Object
- #reload ⇒ Object
Methods included from Enumerable
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
#instances ⇒ Object
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
#each ⇒ Object
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 |
#reload ⇒ Object
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 |