Class: Flapjack::Data::Acknowledgement
- Inherits:
-
Object
- Object
- Flapjack::Data::Acknowledgement
- Includes:
- ActiveModel::Serializers::JSON, Extensions::Associations, Extensions::ShortName, Swagger::Blocks, Zermelo::Records::Stub
- Defined in:
- lib/flapjack/data/acknowledgement.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.
31 32 33 |
# File 'lib/flapjack/data/acknowledgement.rb', line 31 def queue @queue end |
Class Method Details
.jsonapi_associations ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/flapjack/data/acknowledgement.rb', line 155 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 ), :tag => Flapjack::Gateways::JSONAPI::Data::JoinDescriptor.new( :post => true, :number => :singular, :link => false, :includable => false, :type => 'tag', :klass => Flapjack::Data::Tag ) } populate_association_data(@jsonapi_associations) end @jsonapi_associations end |
.jsonapi_methods ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/flapjack/data/acknowledgement.rb', line 143 def self.jsonapi_methods @jsonapi_methods ||= { :post => Flapjack::Gateways::JSONAPI::Data::MethodDescriptor.new( :attributes => [:duration, :summary], :descriptions => { :singular => "Acknowledge a check, or acknowledge all checks linked to a tag.", :multiple => "Acknowledge multiple checks, or checks linked to different tags." } ) } end |
.swagger_included_classes ⇒ Object
138 139 140 141 |
# File 'lib/flapjack/data/acknowledgement.rb', line 138 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 54 55 56 |
# File 'lib/flapjack/data/acknowledgement.rb', line 43 def check=(c) raise "Acknowledgement not saved" unless persisted? raise "Acknowledgement queue not set" if @queue.nil? || @queue.empty? raise "Acknowledgement already sent" if @sent if c.failing && c.enabled @checks = [c] Flapjack::Data::Event.create_acknowledgements( @queue, @checks, :duration => self.duration, :summary => self.summary ) end @sent = true end |
#persisted? ⇒ Boolean
39 40 41 |
# File 'lib/flapjack/data/acknowledgement.rb', line 39 def persisted? !@id.nil? && @saved.is_a?(TrueClass) end |
#save! ⇒ Object
33 34 35 36 37 |
# File 'lib/flapjack/data/acknowledgement.rb', line 33 def save! @id ||= SecureRandom.uuid @duration ||= (4 * 60 * 60) @saved = true end |
#tag=(t) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/flapjack/data/acknowledgement.rb', line 58 def tag=(t) raise "Acknowledgement not saved" unless persisted? raise "Acknowledgement queue not set" if @queue.nil? || @queue.empty? raise "Acknowledgement already sent" if @sent checks = t.checks.intersect(:failing => true, :enabled => true) unless checks.empty? @checks = checks.all Flapjack::Data::Event.create_acknowledgements( @queue, @checks, :duration => self.duration, :summary => self.summary ) end @sent = true end |