diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mauve/alert_group.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/mauve/alert_group.rb b/lib/mauve/alert_group.rb index 7ea7ffb..2f234ec 100644 --- a/lib/mauve/alert_group.rb +++ b/lib/mauve/alert_group.rb @@ -26,7 +26,7 @@ module Mauve # # @return [Array] AlertGroups that match def matches(alert) - grps = all.select { |alert_group| alert_group.includes?(alert) } + grps = find_all { |alert_group| alert_group.includes?(alert) } # # Make sure we always match the last (and therefore default) group. @@ -36,6 +36,28 @@ module Mauve grps end + # + # + # + def find_all(&block) + return all unless block_given? + + all.find_all do |alert_group| + yield(alert_group) + end + end + + # + # + # + def find(&block) + return nil unless block_given? + + all.find do |alert_group| + yield(alert_group) + end + end + # @return [Log4r::Logger] def logger Log4r::Logger.new self.to_s |