aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mauve/alert.rb43
1 files changed, 24 insertions, 19 deletions
diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb
index d27b5d4..5b86437 100644
--- a/lib/mauve/alert.rb
+++ b/lib/mauve/alert.rb
@@ -309,28 +309,22 @@ module Mauve
Server.notification_push([self, at])
end
- # Save an alert, creating a history and notifications, as needed.
#
+ # Notification should happen if
#
- def save
- #
- # Notification should happen if
- #
- # * the alert has just been raised
- # * the alert is raised and its acknowledged status has changed
- # * the alert has just been cleared, and wasn't suppressed before the clear.
- #
- #
- should_notify = (
- (self.raised? and self.was_cleared?) or
- (self.raised? and self.was_acknowledged? != self.acknowledged?) or
- (self.cleared? and self.was_raised? and !self.was_suppressed?)
- )
+ # * the alert has just been raised
+ # * the alert is raised and its acknowledged status has changed
+ # * the alert has just been cleared, and wasn't suppressed before the clear.
+ #
+ #
+ def should_notify?
+ (self.raised? and self.was_cleared?) or
+ (self.raised? and self.was_acknowledged? != self.acknowledged?) or
+ (self.cleared? and self.was_raised? and !self.was_suppressed?)
+ end
- #
- # Set the update type.
- #
- ut = if self.cleared? and !self.was_cleared?
+ def update_type_str
+ if self.cleared? and !self.was_cleared?
"cleared"
elsif self.raised? and !self.was_raised?
"raised"
@@ -341,7 +335,18 @@ module Mauve
else
nil
end
+ end
+
+ # Save an alert, creating a history and notifications, as needed.
+ #
+ #
+ def save
+ should_notify = self.should_notify?
+ #
+ # Set the update type.
+ #
+ ut = self.update_type_str
history = nil
unless ut.nil?