From cbe6e159ea00b7c63279d96c64eb90fdbfd4c275 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Tue, 27 Nov 2012 16:16:00 +0000 Subject: Don't do useless database fetches, when super/dirty_attributes can be used. --- lib/mauve/alert.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/mauve/alert.rb') diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb index 024ce5c..ab13736 100644 --- a/lib/mauve/alert.rb +++ b/lib/mauve/alert.rb @@ -217,19 +217,18 @@ module Mauve # The alert subject # # @return [String] - def subject; attribute_get(:subject) || attribute_get(:source) || "not set" ; end + def subject; super || self.source || "not set" ; end # The alert detail # # @return [String] - def detail; attribute_get(:detail) || "_No detail set._" ; end + def detail; super || "_No detail set._" ; end # # Set the subject -- this clears the cached_alert_group. # def subject=(s) self.cached_alert_group = nil - @subject_ips = nil attribute_set(:subject, s) end @@ -288,7 +287,7 @@ module Mauve # This is to stop datamapper inserting duff dates into the database. # def check_dates - bad_dates = self.attributes.find_all do |key, value| + bad_dates = self.dirty_attributes.find_all do |key, value| value.is_a?(Time) and (value < (Time.now - 3650.days) or value > (Time.now + 3650.days)) end @@ -299,7 +298,6 @@ module Mauve end end - # Remove all history for an alert, when an alert is destroyed. # # -- cgit v1.2.1