Module: Tekeya::Feed::Notification::ClassMethods

Defined in:
lib/tekeya/feed/notification.rb

Instance Method Summary collapse

Instance Method Details

#notify!(to_notify, notification_type, subject, *args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tekeya/feed/notification.rb', line 22

def notify!(to_notify, notification_type, subject, *args)
  options = args.extract_options!
  options[:group] = options[:group].nil? ? true : options[:group]

  actors = []
  args.each do |attachable|
    actors << ::Tekeya::Attachment.new(attachable: attachable)
  end

  to_notify.each do |entity|
    entity.notifications.create notification_type: notification_type, subject: subject, actors: actors, group_with_recent: options[:group]
  end
end