Class: OKComputer::Check
- Inherits:
-
Object
- Object
- OKComputer::Check
- Defined in:
- lib/okcomputer/check.rb
Direct Known Subclasses
ActiveRecordCheck, DefaultCheck, MongoidCheck, ResqueDownCheck, SizeThresholdCheck
Constant Summary collapse
- CALL_DEPRECATION_MESSAGE =
"Deprecation warning: Please define #check rather than defining #call"- CheckNotDefined =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#failure_occurred ⇒ Object
nil by default, only set to true if the check deems itself failed.
-
#message ⇒ Object
nil by default, set by #check to control the output.
-
#registrant_name ⇒ Object
to be set by Registry upon registration.
Instance Method Summary collapse
-
#clear ⇒ Object
Public: Clear any prior failures.
-
#mark_failure ⇒ Object
Public: Mark that this check has failed in some way.
-
#mark_message(message) ⇒ Object
Public: Capture the desired message to display.
-
#run ⇒ Object
Public: Run the check.
-
#success? ⇒ Boolean
Public: Whether the check passed.
-
#to_json(*args) ⇒ Object
Public: The JSON output of performing the check.
-
#to_text ⇒ Object
Public: The text output of performing the check.
Instance Attribute Details
#failure_occurred ⇒ Object
nil by default, only set to true if the check deems itself failed
8 9 10 |
# File 'lib/okcomputer/check.rb', line 8 def failure_occurred @failure_occurred end |
#message ⇒ Object
nil by default, set by #check to control the output
10 11 12 |
# File 'lib/okcomputer/check.rb', line 10 def end |
#registrant_name ⇒ Object
to be set by Registry upon registration
6 7 8 |
# File 'lib/okcomputer/check.rb', line 6 def registrant_name @registrant_name end |
Instance Method Details
#clear ⇒ Object
Public: Clear any prior failures
69 70 71 72 |
# File 'lib/okcomputer/check.rb', line 69 def clear self.failure_occurred = false self. = nil end |
#mark_failure ⇒ Object
Public: Mark that this check has failed in some way
57 58 59 |
# File 'lib/okcomputer/check.rb', line 57 def mark_failure self.failure_occurred = true end |
#mark_message(message) ⇒ Object
Public: Capture the desired message to display
message - Text of the message to display for this check
64 65 66 |
# File 'lib/okcomputer/check.rb', line 64 def () self. = end |
#run ⇒ Object
Public: Run the check
13 14 15 16 |
# File 'lib/okcomputer/check.rb', line 13 def run clear check end |
#success? ⇒ Boolean
Public: Whether the check passed
Returns a boolean
52 53 54 |
# File 'lib/okcomputer/check.rb', line 52 def success? not failure_occurred end |
#to_json(*args) ⇒ Object
Public: The JSON output of performing the check
Returns a String containing JSON
43 44 45 46 47 |
# File 'lib/okcomputer/check.rb', line 43 def to_json(*args) # NOTE swallowing the arguments that Rails passes by default since we don't care. This may prove to be a bad idea # Rails passes stuff like this: {:prefixes=>["ok_computer", "application"], :template=>"show", :layout=>#<Proc>}] {registrant_name => }.to_json end |
#to_text ⇒ Object
Public: The text output of performing the check
Returns a String
36 37 38 |
# File 'lib/okcomputer/check.rb', line 36 def to_text "#{registrant_name}: #{message}" end |