Class: FrenzyBunnies::Health::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/frenzy_bunnies/health/collector.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Collector

Returns a new instance of Collector.



2
3
4
5
6
7
8
9
10
# File 'lib/frenzy_bunnies/health/collector.rb', line 2

def initialize(opts={})
  @providers = []
  Dir["#{File.dirname(__FILE__)}/providers/*.rb"].each do |f| 
    require f
    name = File.basename(f, '.*')
    provider_klass = FrenzyBunnies::Health::Providers.const_get(camelize name)
    @providers << provider_klass.new(opts[name.to_sym])
  end
end

Instance Method Details

#camelize(str) ⇒ Object

real basic camelizer, beware!. meant to avoid including active-support here.



17
18
19
# File 'lib/frenzy_bunnies/health/collector.rb', line 17

def camelize(str)
  str.split('_').map {|s| s.capitalize}.join
end

#collectObject



12
13
14
# File 'lib/frenzy_bunnies/health/collector.rb', line 12

def collect
  @providers.map{|p| p.report }.inject(:merge)
end