Class: UINotifications::Tasks::TaskBulkCancel

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

Instance Method Summary collapse

Constructor Details

#initialize(task, cancelled_length, skipped_length) ⇒ TaskBulkCancel

Returns a new instance of TaskBulkCancel.



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

def initialize(task, cancelled_length, skipped_length)
  @subject = task
  @cancelled_length = cancelled_length
  @skipped_length = skipped_length
end

Instance Method Details

#audienceObject



21
22
23
# File 'app/services/ui_notifications/tasks/task_bulk_cancel.rb', line 21

def audience
  Notification::AUDIENCE_GLOBAL
end

#blueprintObject



31
32
33
# File 'app/services/ui_notifications/tasks/task_bulk_cancel.rb', line 31

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

#createObject



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

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

#messageObject



25
26
27
28
29
# File 'app/services/ui_notifications/tasks/task_bulk_cancel.rb', line 25

def message
  ('%{cancelled} Tasks were cancelled. %{skipped} Tasks were skipped. ' %
    { cancelled: @cancelled_length,
    skipped: @skipped_length })
end