Class: Hyrax::Workflow::AbstractNotification Abstract
- Inherits:
-
Object
- Object
- Hyrax::Workflow::AbstractNotification
- Includes:
- ActionView::Helpers::UrlHelper
- Defined in:
- app/services/hyrax/workflow/abstract_notification.rb
Overview
This class is abstract.
A notification that happens when a state transition occurs. Subclass AbstractNotification to create a notification.
Direct Known Subclasses
ChangesRequiredNotification, DepositedNotification, PendingReviewNotification
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#recipients ⇒ Object
readonly
Returns the value of attribute recipients.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#work_id ⇒ Object
readonly
Returns the value of attribute work_id.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(entity, comment, user, recipients) ⇒ AbstractNotification
constructor
A new instance of AbstractNotification.
Constructor Details
#initialize(entity, comment, user, recipients) ⇒ AbstractNotification
Returns a new instance of AbstractNotification.
41 42 43 44 45 46 47 48 49 |
# File 'app/services/hyrax/workflow/abstract_notification.rb', line 41 def initialize(entity, comment, user, recipients) @work_id = entity.proxy_for.id @title = entity.proxy_for.title.first @comment = comment&.comment.to_s # Convert to hash with indifferent access to allow both string and symbol keys @recipients = recipients.with_indifferent_access @user = user @entity = entity end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
33 34 35 |
# File 'app/services/hyrax/workflow/abstract_notification.rb', line 33 def comment @comment end |
#recipients ⇒ Object (readonly)
Returns the value of attribute recipients.
33 34 35 |
# File 'app/services/hyrax/workflow/abstract_notification.rb', line 33 def recipients @recipients end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
33 34 35 |
# File 'app/services/hyrax/workflow/abstract_notification.rb', line 33 def title @title end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
33 34 35 |
# File 'app/services/hyrax/workflow/abstract_notification.rb', line 33 def user @user end |
#work_id ⇒ Object (readonly)
Returns the value of attribute work_id.
33 34 35 |
# File 'app/services/hyrax/workflow/abstract_notification.rb', line 33 def work_id @work_id end |
Class Method Details
.send_notification(entity:, comment:, user:, recipients:) ⇒ Object
29 30 31 |
# File 'app/services/hyrax/workflow/abstract_notification.rb', line 29 def self.send_notification(entity:, comment:, user:, recipients:) new(entity, comment, user, recipients).call end |
Instance Method Details
#call ⇒ Object
51 52 53 54 55 |
# File 'app/services/hyrax/workflow/abstract_notification.rb', line 51 def call users_to_notify.uniq.each do |recipient| Hyrax::MessengerService.deliver(user, recipient, , subject) end end |