Class: Flapjack::Data::TestNotification
- Inherits:
-
Object
- Object
- Flapjack::Data::TestNotification
- Includes:
- ActiveModel::Serializers::JSON, Extensions::Associations, Extensions::ShortName, Swagger::Blocks, Zermelo::Records::Stub
- Defined in:
- lib/flapjack/data/test_notification.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
Returns the value of attribute queue.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#queue ⇒ Object
Returns the value of attribute queue.
29 30 31 |
# File 'lib/flapjack/data/test_notification.rb', line 29 def queue @queue end |
Class Method Details
.jsonapi_associations ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# 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 ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 |
# 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 ⇒ Object
136 137 138 139 |
# File 'lib/flapjack/data/test_notification.rb', line 136 def self.swagger_included_classes # hack -- hardcoding for now [] end |
Instance Method Details
#check=(c) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# 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? ⇒ Boolean
39 40 41 |
# File 'lib/flapjack/data/test_notification.rb', line 39 def persisted? !@id.nil? && @saved.is_a?(TrueClass) end |
#save! ⇒ Object
34 35 36 37 |
# File 'lib/flapjack/data/test_notification.rb', line 34 def save! @id ||= SecureRandom.uuid @saved = true end |
#tag=(t) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# 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 |