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.
-
#initialize(name) ⇒ Status
constructor
A new instance of Status.
-
#ok(message) ⇒ Object
Add a message indicating that the check passed.
-
#success? ⇒ Boolean
Returns
trueonly if all checks were OK.
Constructor Details
#initialize(name) ⇒ Status
Returns a new instance of Status.
30 31 32 33 |
# File 'lib/is_it_working/status.rb', line 30 def initialize(name) @name = name = [] end |
Instance Attribute Details
#messages ⇒ Object (readonly)
The messages set on the status check.
25 26 27 |
# File 'lib/is_it_working/status.rb', line 25 def end |
#name ⇒ Object (readonly)
The name of the status check for display purposes.
22 23 24 |
# File 'lib/is_it_working/status.rb', line 22 def name @name end |
#time ⇒ Object
The amount of time it takes to complete the status check.
28 29 30 |
# File 'lib/is_it_working/status.rb', line 28 def time @time end |
Instance Method Details
#fail(message) ⇒ Object
Add a message indicating that the check failed.
41 42 43 |
# File 'lib/is_it_working/status.rb', line 41 def fail() << Message.new(, false) end |
#ok(message) ⇒ Object
Add a message indicating that the check passed.
36 37 38 |
# File 'lib/is_it_working/status.rb', line 36 def ok() << Message.new(, true) end |
#success? ⇒ Boolean
Returns true only if all checks were OK.
46 47 48 |
# File 'lib/is_it_working/status.rb', line 46 def success? .all?{|m| m.ok?} end |