Sha256: 841502c044c60d841da3c9cc81272b5d9bb141987670d0a4ee6ae88f200831ac
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
#!/usr/bin/env ruby require 'flapjack/data/message' module Flapjack module Data class Notification attr_accessor :event, :type, :max_notified_severity def self.for_event(event, opts = {}) self.new(:event => event, :type => opts[:type], :max_notified_severity => opts[:max_notified_severity]) end def messages(opts = {}) contacts = opts[:contacts] return [] if contacts.nil? @messages ||= contacts.collect {|contact| # TODO don't include messages here if the contact doesn't have # the medium enabled or has blackholed at this level -- this # will simplify the executive logic contact.media.keys.inject([]) { |ret, mk| m = Flapjack::Data::Message.for_contact(:contact => contact) m.notification = self m.medium = mk m.address = contact.media[mk] ret << m ret } }.flatten end def contents @contents ||= {'event_id' => event.id, 'state' => event.state, 'summary' => event.summary, 'time' => event.time, 'duration' => event.duration || nil, 'notification_type' => type, 'max_notified_severity' => max_notified_severity } end private def initialize(opts = {}) raise "Event not passed" unless event = opts[:event] @event = event @type = opts[:type] @max_notified_severity = opts[:max_notified_severity] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flapjack-0.7.6 | lib/flapjack/data/notification.rb |