3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/unotifier/system_notifier.rb', line 3
def self.notify_system(notification, params = {})
key = notification.key
config = UNotifier.load_notification!(key)
return if config["system"].nil?
raise AttributeMissingError.new(key, "system") unless params
data = config["system"]["keys"].each_with_object({}) do |(head, attributes), obj|
head = head.to_sym
attributes = attributes.map(&:to_sym)
raise AttributeMissingError.new(key, head) unless params.key?(head)
attributes.each { |a| raise AttributeMissingError.new(key, a) unless params[head].keys.include?(a) }
obj[head] = params[head].slice(*attributes)
end
data.merge!(key: notification.key)
UNotifier.configuration.system_providers.each do |provider|
provider.notify notification, data
end
end
|