Class: AppStatus::CheckItem
- Inherits:
-
Object
- Object
- AppStatus::CheckItem
- Defined in:
- app/models/app_status/check_item.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#ms ⇒ Object
readonly
Returns the value of attribute ms.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#proc ⇒ Object
Returns the value of attribute proc.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
- #as_hash ⇒ Object
- #evaluate! ⇒ Object
- #html_description ⇒ Object
-
#initialize(name) ⇒ CheckItem
constructor
A new instance of CheckItem.
- #reset ⇒ Object
- #valid_status?(status) ⇒ Boolean
Constructor Details
#initialize(name) ⇒ CheckItem
Returns a new instance of CheckItem.
8 9 10 11 12 13 14 |
# File 'app/models/app_status/check_item.rb', line 8 def initialize(name) @name = name @proc = nil @description = '' reset end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'app/models/app_status/check_item.rb', line 6 def description @description end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
5 6 7 |
# File 'app/models/app_status/check_item.rb', line 5 def details @details end |
#ms ⇒ Object (readonly)
Returns the value of attribute ms.
5 6 7 |
# File 'app/models/app_status/check_item.rb', line 5 def ms @ms end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'app/models/app_status/check_item.rb', line 5 def name @name end |
#proc ⇒ Object
Returns the value of attribute proc.
6 7 8 |
# File 'app/models/app_status/check_item.rb', line 6 def proc @proc end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'app/models/app_status/check_item.rb', line 5 def status @status end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
5 6 7 |
# File 'app/models/app_status/check_item.rb', line 5 def status_code @status_code end |
Instance Method Details
#as_hash ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'app/models/app_status/check_item.rb', line 45 def as_hash { status: @status, status_code: @status_code, details: @details, ms: @ms } end |
#evaluate! ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/app_status/check_item.rb', line 24 def evaluate! check_start = Time.now status, details = @proc ? @proc.call : [:unknown, "Check is not configured."] check_time = (Time.now - check_start) * 1000 status = status.to_sym if status details = details.to_s if details if ! valid_status?(status) details = "Check returned invalid status '#{status}'. #{details}".strip status = :unknown end @status = status @status_code = CheckCollection.valid_status_map[@status] @details = details @ms = check_time.to_i return @status_code end |
#html_description ⇒ Object
54 55 56 |
# File 'app/models/app_status/check_item.rb', line 54 def html_description Kramdown::Document.new(@description).to_html end |
#reset ⇒ Object
16 17 18 |
# File 'app/models/app_status/check_item.rb', line 16 def reset @result = {} end |
#valid_status?(status) ⇒ Boolean
20 21 22 |
# File 'app/models/app_status/check_item.rb', line 20 def valid_status?(status) CheckCollection.valid_status_map.keys.include?(status) end |