Class: UINotifications::Tasks::TaskBulkStop

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

Instance Method Summary collapse

Constructor Details

#initialize(task, stopped_length, skipped_length) ⇒ TaskBulkStop

Returns a new instance of TaskBulkStop.



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

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

Instance Method Details

#audienceObject



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

def audience
  Notification::AUDIENCE_GLOBAL
end

#blueprintObject



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

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

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'app/services/ui_notifications/tasks/task_bulk_stop.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_stop.rb', line 25

def message
  ('%{stopped} Tasks were stopped. %{skipped} Tasks were already stopped. ' %
    { stopped: @stopped_length,
    skipped: @skipped_length })
end