Sha256: d6c8b0a36b4bfe785815f2af85a96f8aadce86c795e5ff7c3987a82be4f0ff4d

Contents?: true

Size: 1.5 KB

Versions: 56

Compression:

Stored size: 1.5 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 'flapjack/data/contact'

module Flapjack
  module Data
    class Message

      attr_reader :medium, :address, :duration, :contact, :rollup

      def self.for_contact(contact, opts = {})
        self.new(:contact  => contact,
                 :medium   => opts[:medium],
                 :address  => opts[:address],
                 :duration => opts[:duration],
                 :rollup   => opts[:rollup])
      end

      def id
        return @id if @id
        t = Time.now
        # FIXME: consider using a UUID here
        # this is planned to be used as part of alert history keys
        @id = "#{self.object_id.to_i}-#{t.to_i}.#{t.tv_usec}"
      end

      def contents
        c = {'media'              => medium,
             'address'            => address,
             'id'                 => id,
             'rollup'             => rollup,
             'contact_id'         => contact.id,
             'contact_first_name' => contact.first_name,
             'contact_last_name'  => contact.last_name}
        c['duration'] = duration if duration
        c
      end

    private

      def initialize(opts = {})
        @contact  = opts[:contact]
        @medium   = opts[:medium]
        @address  = opts[:address]
        @duration = opts[:duration]
        @rollup   = opts[:rollup]
      end

    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
flapjack-1.2.0rc2 lib/flapjack/data/message.rb
flapjack-1.2.0rc1 lib/flapjack/data/message.rb
flapjack-0.9.5 lib/flapjack/data/message.rb
flapjack-0.9.4 lib/flapjack/data/message.rb
flapjack-1.1.0 lib/flapjack/data/message.rb
flapjack-1.0.0 lib/flapjack/data/message.rb
flapjack-1.0.0rc6 lib/flapjack/data/message.rb
flapjack-1.0.0rc5 lib/flapjack/data/message.rb
flapjack-0.9.3 lib/flapjack/data/message.rb
flapjack-1.0.0rc3 lib/flapjack/data/message.rb
flapjack-1.0.0rc2 lib/flapjack/data/message.rb
flapjack-0.9.2 lib/flapjack/data/message.rb
flapjack-0.9.1 lib/flapjack/data/message.rb
flapjack-1.0.0rc1 lib/flapjack/data/message.rb
flapjack-0.9.0 lib/flapjack/data/message.rb
flapjack-0.8.12 lib/flapjack/data/message.rb
flapjack-0.8.11 lib/flapjack/data/message.rb
flapjack-0.8.10 lib/flapjack/data/message.rb
flapjack-0.8.9 lib/flapjack/data/message.rb
flapjack-0.8.8 lib/flapjack/data/message.rb