Class: Hyrax::Workflow::NotificationConfigurationParameter

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/workflow/notification_configuration_parameter.rb

Overview

Note:

In an effort to appease Rubocop, I’m crafting this parameter object. It makes more sense anyway.

Helps consolidate and map a notification configuration.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason:, scope:, notification_name:, recipients:, notification_type:) ⇒ NotificationConfigurationParameter

Returns a new instance of NotificationConfigurationParameter.



23
24
25
26
27
28
29
# File 'app/services/hyrax/workflow/notification_configuration_parameter.rb', line 23

def initialize(reason:, scope:, notification_name:, recipients:, notification_type:)
  self.reason = reason
  self.scope = scope
  self.notification_name = notification_name
  self.recipients = recipients
  self.notification_type = notification_type
end

Instance Attribute Details

#notification_nameObject

Returns the value of attribute notification_name.



31
32
33
# File 'app/services/hyrax/workflow/notification_configuration_parameter.rb', line 31

def notification_name
  @notification_name
end

#notification_typeObject

Returns the value of attribute notification_type.



31
32
33
# File 'app/services/hyrax/workflow/notification_configuration_parameter.rb', line 31

def notification_type
  @notification_type
end

#reasonObject

Why are we sending the notification?



36
37
38
# File 'app/services/hyrax/workflow/notification_configuration_parameter.rb', line 36

def reason
  @reason
end

#recipientsObject

Returns the value of attribute recipients.



31
32
33
# File 'app/services/hyrax/workflow/notification_configuration_parameter.rb', line 31

def recipients
  @recipients
end

#scopeObject

For the given reason, there is a scope for that reason. Examples of scope include an action name or a state name.



40
41
42
# File 'app/services/hyrax/workflow/notification_configuration_parameter.rb', line 40

def scope
  @scope
end

Class Method Details

.build_from_workflow_action_configuration(workflow_action:, config:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/hyrax/workflow/notification_configuration_parameter.rb', line 8

def self.build_from_workflow_action_configuration(workflow_action:, config:)
  notification_name = config.fetch(:name)
  notification_type = config.fetch(:notification_type)
  recipients = config.slice(:to, :cc, :bcc)
  new(
    notification_name: notification_name,
    reason: Sipity::NotifiableContext::REASON_ACTION_IS_TAKEN,
    recipients: recipients,
    notification_type: notification_type,
    scope: workflow_action
  )
end