Class: Webhookdb::Organization::Alerting
- Inherits:
-
Object
- Object
- Webhookdb::Organization::Alerting
- Includes:
- Appydays::Configurable
- Defined in:
- lib/webhookdb/organization/alerting.rb
Instance Attribute Summary collapse
-
#org ⇒ Object
readonly
Returns the value of attribute org.
Instance Method Summary collapse
-
#dispatch_alert(message_template) ⇒ Object
Dispatch the message template to administrators of the org.
-
#initialize(org) ⇒ Alerting
constructor
A new instance of Alerting.
Constructor Details
#initialize(org) ⇒ Alerting
Returns a new instance of Alerting.
15 16 17 |
# File 'lib/webhookdb/organization/alerting.rb', line 15 def initialize(org) @org = org end |
Instance Attribute Details
#org ⇒ Object (readonly)
Returns the value of attribute org.
13 14 15 |
# File 'lib/webhookdb/organization/alerting.rb', line 13 def org @org end |
Instance Method Details
#dispatch_alert(message_template) ⇒ Object
Dispatch the message template to administrators of the org.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webhookdb/organization/alerting.rb', line 21 def dispatch_alert() unless .respond_to?(:signature) raise Webhookdb::InvalidPrecondition, "message template #{.template_name} must define a #signature method, " \ "which is a unique identity for this error type, used for grouping and idempotency" end signature = .signature self.org.admin_customers.each do |c| idemkey = "orgalert-#{signature}-#{c.id}" Webhookdb::Idempotency.every(Webhookdb::Organization::Alerting.interval).under_key(idemkey) do .dispatch_email(c) end end end |