Sha256: f3ae4aade5529acf424d2beb0ae10e480463fd546caeca937cbc9d67ae718c6b

Contents?: true

Size: 800 Bytes

Versions: 2

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

module NotificationPusher
  class DeliveryMethodConfiguration
    def initialize(class_name, options = {})
      @klass = NotificationPusher::DeliveryMethod.const_get(class_name)
      @options = options
    end

    def call(notification, options = {})
      options = @options.merge!(options)

      @klass.new(notification, options).call
    end

    def self.find_by_name(name)
      NotificationPusher.configuration.delivery_methods[name]
    end

    def self.find_by_name!(name)
      find_by_name(name) ||
        raise(ArgumentError,
              "Could not find a registered delivery method for :#{name}. " \
              'Make sure you register it with ' \
              "config.register_delivery_method :#{name}, :CustomDeliveryMethod")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
notification-pusher-3.0.2 lib/notification_pusher/delivery_method_configuration.rb
notification-pusher-2.0.0 lib/notification_pusher/delivery_method_configuration.rb