Class: Steto::ProcCheck

Inherits:
BaseCheck show all
Defined in:
lib/steto/proc_check.rb

Instance Attribute Summary collapse

Attributes inherited from BaseCheck

#name, #text

Instance Method Summary collapse

Methods inherited from BaseCheck

#attributes=, #check_if_needed, #status, #status=, #to_json

Constructor Details

#initialize(attributes = {}, &block) ⇒ ProcCheck

Returns a new instance of ProcCheck.



6
7
8
9
# File 'lib/steto/proc_check.rb', line 6

def initialize(attributes = {}, &block)
  self.attributes = attributes
  self.block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



4
5
6
# File 'lib/steto/proc_check.rb', line 4

def block
  @block
end

Instance Method Details

#checkObject



11
12
13
# File 'lib/steto/proc_check.rb', line 11

def check
  self.status = status_from_response(block.call)
end

#status_from_response(response) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/steto/proc_check.rb', line 15

def status_from_response(response)
  case response
  when Steto::Status
    response
  when Symbol
    Status.new(response)
  when true
    Status.new(:ok)
  when false
    Status.new(:critical)
  when nil
    Status.new(:unknown)
  end
end