From fd23821950f0562a8995735105cd31fdc6d55933 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 22 Jul 2011 16:55:01 +0100 Subject: * 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 --- lib/mauve/alert_group.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'lib/mauve/alert_group.rb') 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) -- cgit v1.2.3