Class: HealthRails::HealthCheck
- Inherits:
-
Object
- Object
- HealthRails::HealthCheck
- Defined in:
- lib/health_rails/health_check.rb
Class Method Summary collapse
Instance Method Summary collapse
- #all_ok? ⇒ Boolean
- #check(description) ⇒ Object
- #checks ⇒ Object
- #error_messages ⇒ Object
- #errors ⇒ Object
- #process_check(description) ⇒ Object
- #process_checks ⇒ Object
Class Method Details
.check(description, auto_activated, &block) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/health_rails/health_check.rb', line 41 def check(description, auto_activated, &block) if auto_activated && !HealthRails.health_checks.include?(description) HealthRails.health_checks << description end checks[description] = block end |
.checks ⇒ Object
48 49 50 |
# File 'lib/health_rails/health_check.rb', line 48 def checks @@checks ||= {} end |
Instance Method Details
#all_ok? ⇒ Boolean
3 4 5 6 |
# File 'lib/health_rails/health_check.rb', line 3 def all_ok? process_checks !errors.any? end |
#check(description) ⇒ Object
8 9 10 |
# File 'lib/health_rails/health_check.rb', line 8 def check(description) checks[description] end |
#checks ⇒ Object
12 13 14 |
# File 'lib/health_rails/health_check.rb', line 12 def checks HealthCheck.checks end |
#error_messages ⇒ Object
16 17 18 |
# File 'lib/health_rails/health_check.rb', line 16 def errors.join("\n") end |
#errors ⇒ Object
20 21 22 |
# File 'lib/health_rails/health_check.rb', line 20 def errors @errors ||= [] end |
#process_check(description) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/health_rails/health_check.rb', line 24 def process_check(description) begin check(description).call rescue HealthCheckFailure => errors << "#{description}: #{error_message}" end end |
#process_checks ⇒ Object
32 33 34 35 36 37 |
# File 'lib/health_rails/health_check.rb', line 32 def process_checks checks.each do |description, proc| next unless HealthRails.health_checks.include?(description) process_check(description) end end |