Sha256: afc4948e5e44ccf4abb8d7104d9213c63cdf106cd36112ec026d9ea2b7af85ae

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

#!/usr/bin/env ruby

# 'Notification' refers to the template object created when an event occurs,
# from which individual 'Message' objects are created, one for each
# contact+media recipient.

require 'zermelo/records/redis'

module Flapjack
  module Data
    class Notification

      include Zermelo::Records::RedisSet
      include Flapjack::Data::Extensions::ShortName

      define_attributes :severity           => :string,
                        :duration           => :integer,
                        :condition_duration => :float,
                        :event_hash         => :string

      belongs_to :check, :class_name => 'Flapjack::Data::Check',
        :inverse_of => :notifications

      has_one :state, :class_name => 'Flapjack::Data::State',
        :inverse_of => :notification, :after_clear => :destroy_state

      def self.destroy_state(notification_id, st_id)
        # won't be deleted if still referenced elsewhere -- see the State
        # before_destroy callback
        Flapjack::Data::State.intersect(:id => st_id).destroy_all
      end

      validates :severity,
        :inclusion => {:in => Flapjack::Data::Condition.unhealthy.keys +
                              Flapjack::Data::Condition.healthy.keys }

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flapjack-2.0.0 lib/flapjack/data/notification.rb
flapjack-2.0.0rc1 lib/flapjack/data/notification.rb
flapjack-2.0.0b1 lib/flapjack/data/notification.rb