Class: Diagnostics::Check

Inherits:
Struct
  • Object
show all
Defined in:
lib/diagnostics/check.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clsObject

Returns the value of attribute cls

Returns:

  • (Object)

    the current value of cls



2
3
4
# File 'lib/diagnostics/check.rb', line 2

def cls
  @cls
end

Class Method Details

.add(cls) ⇒ Object



4
5
6
7
# File 'lib/diagnostics/check.rb', line 4

def self.add(cls)
  Diagnostics.checks << check = new(cls)
  check
end

.find(name) ⇒ Object



9
10
11
# File 'lib/diagnostics/check.rb', line 9

def self.find(name)
  Diagnostics.checks.select {|c| c.name == name.to_s }[0]
end

Instance Method Details

#dataObject



42
43
44
45
46
47
48
# File 'lib/diagnostics/check.rb', line 42

def data
  @data_method_result ||= if instance.respond_to?(:data)
    instance.data.call(data_group) && data_group
  else
    data_group
  end
end

#failed?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/diagnostics/check.rb', line 29

def failed?
  @failed_method_result ||= call_method(:failed) || (
    !passed? if instance.respond_to?(:passed)
  )
end

#instanceObject



17
18
19
# File 'lib/diagnostics/check.rb', line 17

def instance
  @instance ||= cls.new
end

#nameObject



13
14
15
# File 'lib/diagnostics/check.rb', line 13

def name
  cls.name
end

#passed?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/diagnostics/check.rb', line 21

def passed?
  @passed_method_result ||= call_method(:passed)
end

#statusObject



35
36
37
38
39
40
# File 'lib/diagnostics/check.rb', line 35

def status
  return :passed  if passed?
  return :warning if warning?
  return :failed  if failed?
  :none
end

#warning?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/diagnostics/check.rb', line 25

def warning?
  @warning_method_result ||= call_method(:warning)
end