class Flapjack::Data::TestNotification
Attributes
queue[RW]
Public Class Methods
jsonapi_associations()
click to toggle source
# File lib/flapjack/data/test_notification.rb, line 154 def self.jsonapi_associations unless instance_variable_defined?('@jsonapi_associations') @jsonapi_associations = { :check => Flapjack::Gateways::JSONAPI::Data::JoinDescriptor.new( :post => true, :number => :singular, :link => false, :includable => false, :type => 'check', :klass => Flapjack::Data::Check, :descriptions => { :post => "Creates a simulated event for this check." } ), :tag => Flapjack::Gateways::JSONAPI::Data::JoinDescriptor.new( :post => true, :number => :singular, :link => false, :includable => false, :type => 'tag', :klass => Flapjack::Data::Tag, :descriptions => { :post => "Creates a simulated event for all checks associated with this tag." } ) } populate_association_data(@jsonapi_associations) end @jsonapi_associations end
jsonapi_methods()
click to toggle source
# File lib/flapjack/data/test_notification.rb, line 141 def self.jsonapi_methods @jsonapi_methods ||= { :post => Flapjack::Gateways::JSONAPI::Data::MethodDescriptor.new( :attributes => [:condition, :summary], :descriptions => { :singular => "Create a simulated event for a check, or checks linked to a tag.", :multiple => "Create simulated events for a check, or checks linked to a tag.", } ) } end
swagger_included_classes()
click to toggle source
# File lib/flapjack/data/test_notification.rb, line 136 def self.swagger_included_classes # hack -- hardcoding for now [] end
Public Instance Methods
check=(c)
click to toggle source
# File lib/flapjack/data/test_notification.rb, line 43 def check=(c) raise "Test notification not saved" unless persisted? raise "Test notification queue not set" if @queue.nil? || @queue.empty? raise "Test notification already sent" if @sent Flapjack::Data::Event.test_notifications( @queue, [c], :condition => self.condition, :summary => self.summary ) @sent = true end
persisted?()
click to toggle source
# File lib/flapjack/data/test_notification.rb, line 39 def persisted? !@id.nil? && @saved.is_a?(TrueClass) end
save!()
click to toggle source
# File lib/flapjack/data/test_notification.rb, line 34 def save! @id ||= SecureRandom.uuid @saved = true end
tag=(t)
click to toggle source
# File lib/flapjack/data/test_notification.rb, line 55 def tag=(t) raise "Test notification not saved" unless persisted? raise "Test notification queue not set" if @queue.nil? || @queue.empty? raise "Test notification already sent" if @sent checks = t.checks unless checks.empty? Flapjack::Data::Event.test_notifications( @queue, checks.all, :condition => self.condition, :summary => self.summary ) end @sent = true end