Sha256: b081516528c5e67bf714648421001fe340b4fceb9c08acbc5528c0a1250385f3
Contents?: true
Size: 841 Bytes
Versions: 2
Compression:
Stored size: 841 Bytes
Contents
module MiniCheck class Check attr_accessor :name attr_accessor :healthy attr_accessor :action attr_accessor :exception def initialize args = {}, &block args = {name: args} if !args.is_a?(Hash) args[:action] = block if block_given? set_attributes args end def healthy? !!healthy end def run begin self.healthy = action.call self.exception = nil rescue Exception => e self.healthy = false self.exception = e end end def to_hash {}.tap do |h| h[:healthy] = healthy? h[:error] = {message: exception.message, stack: exception.backtrace} if exception end end private def set_attributes args = {} args.each do |k,v| send("#{k}=", v) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mini_check-0.1.1 | lib/mini_check/check.rb |
mini_check-0.1.0 | lib/mini_check/check.rb |