Sha256: 301271566a2e3329b4dd32dc6a90a04fe6e513c8b3084e3ac209f1bd4943e970

Contents?: true

Size: 1.51 KB

Versions: 58

Compression:

Stored size: 1.51 KB

Contents

module Hyrax
  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

58 entries across 58 versions & 2 rubygems

Version Path
hyrax-2.9.6 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.9.5 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.9.4 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.9.3 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.9.2 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.9.1 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.9.0 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.8.0 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.7.2 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.7.1 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.7.0 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.6.0 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-3.0.0.pre.rc1 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-3.0.0.pre.beta3 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.5.1 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.5.0 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-3.0.0.pre.beta2 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.4.1 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-3.0.0.pre.beta1 app/services/hyrax/workflow/notification_configuration_parameter.rb
hyrax-2.4.0 app/services/hyrax/workflow/notification_configuration_parameter.rb