Class: IsItWorking::Status
- Inherits:
-
Object
- Object
- IsItWorking::Status
- Defined in:
- lib/is_it_working/status.rb
Overview
This class is used to pass the status of a monitoring check. Each status can have multiple messages added to it by calling the ok
or fail
methods. The status check will only be considered a success if all messages are ok.
Defined Under Namespace
Classes: Message
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
The messages set on the status check.
-
#name ⇒ Object
readonly
The name of the status check for display purposes.
-
#time ⇒ Object
The amount of time it takes to complete the status check.
Instance Method Summary collapse
-
#fail(message) ⇒ Object
Add a message indicating that the check failed.
- #info(message) ⇒ Object
-
#initialize(name) ⇒ Status
constructor
A new instance of Status.
-
#ok(message) ⇒ Object
Add a message indicating that the check passed.
-
#success? ⇒ Boolean
Returns
true
only if all checks were OK.
Constructor Details
#initialize(name) ⇒ Status
Returns a new instance of Status.
38 39 40 41 |
# File 'lib/is_it_working/status.rb', line 38 def initialize(name) @name = name @messages = [] end |
Instance Attribute Details
#messages ⇒ Object (readonly)
The messages set on the status check.
33 34 35 |
# File 'lib/is_it_working/status.rb', line 33 def @messages end |
#name ⇒ Object (readonly)
The name of the status check for display purposes.
30 31 32 |
# File 'lib/is_it_working/status.rb', line 30 def name @name end |
#time ⇒ Object
The amount of time it takes to complete the status check.
36 37 38 |
# File 'lib/is_it_working/status.rb', line 36 def time @time end |
Instance Method Details
#fail(message) ⇒ Object
Add a message indicating that the check failed.
53 54 55 |
# File 'lib/is_it_working/status.rb', line 53 def fail() @messages << Message.new(, :fail) end |
#info(message) ⇒ Object
48 49 50 |
# File 'lib/is_it_working/status.rb', line 48 def info() @messages << Message.new(, :info) end |
#ok(message) ⇒ Object
Add a message indicating that the check passed.
44 45 46 |
# File 'lib/is_it_working/status.rb', line 44 def ok() @messages << Message.new(, :ok) end |
#success? ⇒ Boolean
Returns true
only if all checks were OK.
58 59 60 |
# File 'lib/is_it_working/status.rb', line 58 def success? @messages.all?{|m| m.ok?} end |