aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/history.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mauve/history.rb')
-rw-r--r--lib/mauve/history.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/mauve/history.rb b/lib/mauve/history.rb
index 6c4969b..1c2cdf4 100644
--- a/lib/mauve/history.rb
+++ b/lib/mauve/history.rb
@@ -12,10 +12,16 @@ module Mauve
property :id, Serial
property :alert_id, Integer, :required => true
property :type, String, :required => true, :default => "unknown"
- property :event, Text, :required => true
- property :created_at, DateTime
+ property :event, Text, :required => true, :default => "Nothing set"
+ property :created_at, DateTime, :required => true
belongs_to :alert
+
+ before :valid?, :set_created_at
+
+ def set_created_at(context = :default)
+ self.created_at = Time.now unless self.created_at.is_a?(Time) or self.created_at.is_a?(DateTime)
+ end
def logger
Log4r::Logger.new self.class.to_s