Sha256: d98a5f52bd5ea03c499e11ae751d3414519976c3f95c58b2cc4e887d6d05a15b
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
module Diagnostics class Check < Struct.new(:cls) def self.add(cls) Diagnostics.checks << check = new(cls) check end def self.find(name) Diagnostics.checks.select {|c| c.name == name.to_s }[0] end def name cls.name end def instance @instance ||= cls.new end def passed? @passed_method_result ||= call_method(:passed) end def warning? @warning_method_result ||= call_method(:warning) end def failed? @failed_method_result ||= call_method(:failed) end def status return :passed if passed? return :warning if warning? return :failed if failed? :none end def data @data_method_result ||= if instance.respond_to?(:data) instance.data.call(data_group) && data_group else data_group end end private def data_group @data_group ||= DataGroup.new end def call_method(meth) instance.respond_to?(meth) && instance.send(meth) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
diagnostics-0.0.3 | lib/diagnostics/check.rb |