Class: FrenzyBunnies::Health::Collector
- Inherits:
-
Object
- Object
- FrenzyBunnies::Health::Collector
- Defined in:
- lib/frenzy_bunnies/health/collector.rb
Instance Method Summary collapse
-
#camelize(str) ⇒ Object
real basic camelizer, beware!.
- #collect ⇒ Object
-
#initialize(opts = {}) ⇒ Collector
constructor
A new instance of Collector.
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 |
#collect ⇒ Object
12 13 14 |
# File 'lib/frenzy_bunnies/health/collector.rb', line 12 def collect @providers.map{|p| p.report }.inject(:merge) end |