Sha256: 965a16781e9e0ce0ee5f1d93064cdaf0475873616185227af304d76f81b5bd8e
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
module StatusCat class Status # Returns an array of instances of StatusCat::Checkers::Base subclasses def self.all StatusCat::Config.instance.enabled.map { |name| factory( name ) } end # 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 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 # Emails ::failed list if it is not empty def self.cron checkers = self.failed StatusCat::StatusMailer.failure( checkers ).deliver unless checkers.empty? end # Constructs a checker instance given it's name def self.factory( name ) ( 'StatusCat::Checkers::' + name.to_s.classify ).constantize.new end # Returns an array of failed instances of ::all def self.failed self.all.map { |checker| checker.status.nil? ? nil : checker }.compact end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
status_cat-0.1.0 | lib/status_cat/status.rb |
status_cat-0.0.9 | lib/status_cat/status.rb |
status_cat-0.0.8 | lib/status_cat/status.rb |