Module: Noticent
- Defined in:
- lib/noticent.rb,
lib/noticent/view.rb,
lib/noticent/config.rb,
lib/noticent/errors.rb,
lib/noticent/opt_in.rb,
lib/noticent/channel.rb,
lib/noticent/version.rb,
lib/noticent/proc_map.rb,
lib/noticent/dispatcher.rb,
lib/noticent/definitions/alert.rb,
lib/noticent/definitions/hooks.rb,
lib/noticent/definitions/scope.rb,
lib/generators/noticent/noticent.rb,
lib/noticent/definitions/channel.rb,
lib/noticent/definitions/product.rb,
lib/noticent/definitions/product_group.rb,
lib/noticent/active_record_opt_in_provider.rb
Defined Under Namespace
Modules: Definitions, Generators
Classes: ActiveRecordOptInProvider, BadConfiguration, Channel, Config, Dispatcher, Error, InvalidAlert, InvalidPayload, InvalidScope, MissingConfiguration, NoCurrentUser, OptIn, ProcMap, View, ViewNotFound
Class Method Summary
collapse
Class Method Details
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# 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!
@config.create_dynamics
@config
end
|
.notify(alert_name, payload) ⇒ Object
26
27
28
29
30
31
32
|
# 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:) ⇒ Object
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# 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
|