lib/liquid/health_checks.rb in liquid-ext-3.5.0 vs lib/liquid/health_checks.rb in liquid-ext-3.5.2

- old
+ new

@@ -21,21 +21,35 @@ end @@checks = {} @@callbacks = [] + def self.register(name, &block) + @@checks[name.to_s] = block + end + def self.inherited(child) @@checks[child.name.demodulize] = child end def self.callback(cb = nil, &block) @@callbacks << (cb || block) end def self.run - @@checks.inject({}) do |result, (name, handler)| - result[name] = handler.new.execute - result + @@checks.inject({}) do |results, (name, handler)| + if handler.is_a? Proc + result = handler.call + else + result = handler.new.execute + end + + unless result.is_a? Result + result = Result.new(result , nil, nil) + end + + results[name] = result + results end end def self.poll(interval = 5) loop do