Sha256: a1f65598830ade5df06010138a94b4a3b14d8a10a80ee872573aa8e56b31b25b

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

module CurationConcerns
  module Workflow
    # Helps consolidate and map a notification configuration.
    #
    # @note In an effort to appease Rubocop, I'm crafting this parameter object. It makes more sense anyway.
    class NotificationConfigurationParameter
      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

      include Dry::Equalizer(:reason, :scope, :notification_name, :recipients, :notification_type)

      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

      attr_accessor :notification_name, :recipients, :notification_type

      # Why are we sending the notification?
      #
      # @see Sipity::NotifiableContext::REASON_ACTION_IS_TAKEN
      attr_accessor :reason

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.7 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-2.0.0 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-2.0.0.rc2 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.6 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.5 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.4 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.3 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.2 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-2.0.0.rc1 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.1 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.0 app/services/curation_concerns/workflow/notification_configuration_parameter.rb
curation_concerns-1.7.0.beta1 app/services/curation_concerns/workflow/notification_configuration_parameter.rb