Class: UINotifications::Tasks::TaskPausedOwner

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

Instance Method Summary collapse

Methods inherited from Base

#initialize, #initiator, #troubleshooting_help_generator

Constructor Details

This class inherits a constructor from UINotifications::Tasks::Base

Instance Method Details

#blueprintObject



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

def blueprint
  @blueprint ||= NotificationBlueprint.unscoped.find_by(:name => 'tasks_paused_owner')
end

#deliver!Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/ui_notifications/tasks/task_paused_owner.rb', line 4

def deliver!
  notification = ::Notification.new(
    :audience => Notification::AUDIENCE_USER,
    :notification_blueprint => blueprint,
    :initiator => initiator,
    :message => message,
    :subject => subject
  )
  notification.send(:set_custom_attributes) # to add links from blueprint
  notification.actions['links'] ||= []
  if troubleshooting_help_generator
    notification.actions['links'].concat(troubleshooting_help_generator.links.map { |l| l.to_h(capitalize_title: true) })
  end
  notification.save!
  notification
end

#messageObject



25
26
27
# File 'app/services/ui_notifications/tasks/task_paused_owner.rb', line 25

def message
  StringParser.new(blueprint.message, subject: subject.action).to_s
end