Class: Sufia::Workflow::AbstractNotification

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
app/services/sufia/workflow/abstract_notification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity, comment, user, recipients) ⇒ AbstractNotification

Returns a new instance of AbstractNotification.



12
13
14
15
16
17
18
19
# File 'app/services/sufia/workflow/abstract_notification.rb', line 12

def initialize(entity, comment, user, recipients)
  @work_id = entity.proxy_for_global_id.sub(/.*\//, '')
  @title = entity.proxy_for.title.first
  @comment = comment.respond_to?(:comment) ? comment.comment.to_s : ''
  @recipients = recipients
  @user = user
  @entity = entity
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



10
11
12
# File 'app/services/sufia/workflow/abstract_notification.rb', line 10

def comment
  @comment
end

#recipientsObject (readonly)

Returns the value of attribute recipients.



10
11
12
# File 'app/services/sufia/workflow/abstract_notification.rb', line 10

def recipients
  @recipients
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'app/services/sufia/workflow/abstract_notification.rb', line 10

def title
  @title
end

#userObject (readonly)

Returns the value of attribute user.



10
11
12
# File 'app/services/sufia/workflow/abstract_notification.rb', line 10

def user
  @user
end

#work_idObject (readonly)

Returns the value of attribute work_id.



10
11
12
# File 'app/services/sufia/workflow/abstract_notification.rb', line 10

def work_id
  @work_id
end

Class Method Details

.send_notification(entity:, comment:, user:, recipients:) ⇒ Object



6
7
8
# File 'app/services/sufia/workflow/abstract_notification.rb', line 6

def self.send_notification(entity:, comment:, user:, recipients:)
  new(entity, comment, user, recipients).call
end

Instance Method Details

#callObject



21
22
23
# File 'app/services/sufia/workflow/abstract_notification.rb', line 21

def call
  user.send_message(users_to_notify.uniq, message, subject)
end