Class: Eventifier::NotificationTranslator

Inherits:
Object
  • Object
show all
Defined in:
lib/eventifier/notification_translator.rb

Instance Method Summary collapse

Constructor Details

#initialize(prefix, options, *args) ⇒ NotificationTranslator

Returns a new instance of NotificationTranslator.



2
3
4
5
# File 'lib/eventifier/notification_translator.rb', line 2

def initialize(prefix, options, *args)
  @prefix, @options = prefix, options
  @event  = ActiveSupport::Notifications::Event.new(*args).payload[:event]
end

Instance Method Details

#translateObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/eventifier/notification_translator.rb', line 7

def translate
  return if skip?
  users_and_relations do |user, relations|
    next if user == event.user && !options[:notify_self]
    next if skip?(user)

    Eventifier::Notification.create event: event, user: user,
      relations: relations

    Eventifier::Delivery.deliver_for user if options[:email] == :immediate
  end
end