module Noticent
Public Class Methods
configuration()
click to toggle source
# File lib/noticent/config.rb, line 22 def self.configuration @config || (raise Noticent::MissingConfiguration) end
configure(options = {}, &block)
click to toggle source
# File lib/noticent/config.rb, line 4 def self.configure(options = {}, &block) if ENV["NOTICENT_RSPEC"] == "1" options = options.merge( base_module_name: "Noticent::Testing", base_dir: File.expand_path("#{File.dirname(__FILE__)}/../../testing"), halt_on_error: true, ) end @config = Noticent::Config::Builder.new(options, &block).build @config.validate! # construct dynamics @config.create_dynamics @config end
notify(alert_name, payload)
click to toggle source
# File lib/noticent/config.rb, line 26 def self.notify(alert_name, payload) engine = Noticent::Dispatcher.new(@config, alert_name, payload) return if engine.notifiers.nil? engine.dispatch end
setup_recipient(recipient_id:, scope:, entity_ids:)
click to toggle source
recipient is the recipient object id entities is an array of all entity ids this recipient needs to opt in based on the alert defaults scope is the name of the scope these entities belong to
# File lib/noticent/config.rb, line 37 def self.setup_recipient(recipient_id:, scope:, entity_ids:) raise ArgumentError, "no scope named '#{scope}' found" if @config.scopes[scope].nil? alerts = @config.alerts_by_scope(scope) alerts.each do |alert| channels = @config.alert_channels(alert.name) channels.each do |channel| next unless alert.default_for(channel.name) entity_ids.each do |entity_id| @config.opt_in_provider.opt_in(recipient_id: recipient_id, scope: scope, entity_id: entity_id, alert_name: alert.name, channel_name: channel.name) end end end end