aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/alert_group.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-22 16:55:54 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-22 16:55:54 +0100
commit25b32914b72a5f709eca773f3511cc89c2e710c2 (patch)
tree4dab9e78e4c6b49220a837b38d463328c05e2983 /lib/mauve/alert_group.rb
parent3185e5d746abda1b7f42ecdbd74ec14359fda3bc (diff)
parentfd23821950f0562a8995735105cd31fdc6d55933 (diff)
merge
Diffstat (limited to 'lib/mauve/alert_group.rb')
-rw-r--r--lib/mauve/alert_group.rb15
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)