Class: StatusCat::Status
- Inherits:
-
Object
- Object
- StatusCat::Status
- Defined in:
- lib/status_cat/status.rb
Class Method Summary collapse
-
.all ⇒ Object
Returns an array of instances of StatusCat::Checkers::Base subclasses.
-
.check(which = :all) ⇒ Object
By default, returns all checkers If given a list of checker names, returns an array of those checkers If given a single checker name, just returns that checker.
-
.cron ⇒ Object
Emails ::failed list if it is not empty.
-
.factory(name) ⇒ Object
Constructs a checker instance given it’s name.
-
.failed ⇒ Object
Returns an array of failed instances of ::all.
Class Method Details
.all ⇒ Object
Returns an array of instances of StatusCat::Checkers::Base subclasses
6 7 8 |
# File 'lib/status_cat/status.rb', line 6 def self.all StatusCat::Config.instance.enabled.map { |name| factory(name) } end |
.check(which = :all) ⇒ Object
By default, returns all checkers If given a list of checker names, returns an array of those checkers If given a single checker name, just returns that checker
13 14 15 16 17 |
# File 'lib/status_cat/status.rb', line 13 def self.check(which = :all) return all if which == :all return factory(which) unless which.is_a?(Array) return which.map { |name| factory(name) } end |
.cron ⇒ Object
Emails ::failed list if it is not empty
20 21 22 23 |
# File 'lib/status_cat/status.rb', line 20 def self.cron checkers = failed StatusCat::StatusMailer.failure(checkers).deliver_now unless checkers.empty? end |
.factory(name) ⇒ Object
Constructs a checker instance given it’s name
26 27 28 |
# File 'lib/status_cat/status.rb', line 26 def self.factory(name) ('StatusCat::Checkers::' + name.to_s.classify).constantize.new end |
.failed ⇒ Object
Returns an array of failed instances of ::all
31 32 33 |
# File 'lib/status_cat/status.rb', line 31 def self.failed all.map { |checker| checker.status.nil? ? nil : checker }.compact end |