diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
commit | fd23821950f0562a8995735105cd31fdc6d55933 (patch) | |
tree | 967df2f5647803a6c46f4d52003b2231c1de72cb /lib/mauve/alert_group.rb | |
parent | d3a3cfef9650b08f62db62bd7e86b673f9d77d0b (diff) |
* Rejigged configuration
* Added --test and --verbose flags for the server config
* Started proper test suite
* Config parsing now gives more sensible errors + backtrace
* Rejigged people and source lists
Diffstat (limited to 'lib/mauve/alert_group.rb')
-rw-r--r-- | lib/mauve/alert_group.rb | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/mauve/alert_group.rb b/lib/mauve/alert_group.rb index bfdb3cf..6cff33b 100644 --- a/lib/mauve/alert_group.rb +++ b/lib/mauve/alert_group.rb @@ -16,7 +16,7 @@ module Mauve class << self def matches(alert) - grps = all.select { |alert_group| alert_group.matches_alert?(alert) } + grps = all.select { |alert_group| alert_group.includes?(alert) } # # Make sure we always match the last (and therefore default) group. @@ -90,7 +90,7 @@ module Mauve # The list of current raised alerts in this group. # def current_alerts - Alert.all(:cleared_at => nil, :raised_at.not => nil).select { |a| matches_alert?(a) } + Alert.all(:cleared_at => nil, :raised_at.not => nil).select { |a| includes?(a) } end # Decides whether a given alert belongs in this group according to its @@ -98,7 +98,7 @@ module Mauve # # @param [Alert] alert An alert to test for belongness to group. # @return [Boolean] Success or failure. - def matches_alert?(alert) + def includes?(alert) unless alert.is_a?(Alert) logger.error "Got given a #{alert.class} instead of an Alert!" @@ -106,14 +106,11 @@ module Mauve return false end - result = alert.instance_eval(&self.includes) - if true == result or - true == result.instance_of?(MatchData) - return true - end - return false + alert.instance_eval(&self.includes) ? true : false end + alias matches_alert? includes? + def logger ; self.class.logger ; end # Signals that a given alert (which is assumed to belong in this group) |