Class: UINotifications::Tasks::TaskBulkResume

Inherits:
Base
  • Object
show all
Defined in:
app/services/ui_notifications/tasks/task_bulk_resume.rb

Instance Method Summary collapse

Constructor Details

#initialize(task, resumed_length, failed_length, skipped_length) ⇒ TaskBulkResume

Returns a new instance of TaskBulkResume.



4
5
6
7
8
9
# File 'app/services/ui_notifications/tasks/task_bulk_resume.rb', line 4

def initialize(task, resumed_length, failed_length, skipped_length)
  @subject = task
  @resumed_length = resumed_length
  @failed_length = failed_length
  @skipped_length = skipped_length
end

Instance Method Details

#audienceObject



22
23
24
# File 'app/services/ui_notifications/tasks/task_bulk_resume.rb', line 22

def audience
  Notification::AUDIENCE_USER
end

#blueprintObject



33
34
35
# File 'app/services/ui_notifications/tasks/task_bulk_resume.rb', line 33

def blueprint
  @blueprint ||= NotificationBlueprint.find_by(name: 'tasks_bulk_resume')
end

#createObject



11
12
13
14
15
16
17
18
19
20
# File 'app/services/ui_notifications/tasks/task_bulk_resume.rb', line 11

def create
  Notification.create!(
    initiator: initiator,
    audience: audience,
    subject: subject,
    notification_blueprint: blueprint,
    message: message,
    notification_recipients: [NotificationRecipient.create({ :user => User.current })]
  )
end

#messageObject



26
27
28
29
30
31
# File 'app/services/ui_notifications/tasks/task_bulk_resume.rb', line 26

def message
  ('%{resumed} Tasks were resumed. %{failed} Tasks failed to resume. %{skipped} Tasks were skipped. ' %
    { resumed: @resumed_length,
    failed: @failed_length,
    skipped: @skipped_length })
end