1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/services/notification_center.rb

21 lines
732 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# send notification to one or several receiver with a type, an attached object and an optional meta data
2015-05-05 03:10:25 +02:00
class NotificationCenter
def self.call(type: nil, receiver: nil, attached_object: nil, meta_data: {})
2015-05-05 03:10:25 +02:00
if receiver.respond_to?(:each)
receiver.each do |user|
Notification.new(meta_data: meta_data)
.send_notification(type: type, attached_object: attached_object)
.to(user)
.deliver_later
2015-05-05 03:10:25 +02:00
end
else
Notification.new(meta_data: meta_data)
.send_notification(type: type, attached_object: attached_object)
.to(receiver)
.deliver_later
2015-05-05 03:10:25 +02:00
end
end
end