Sha256: 55a9304cdd10eae51b35215f61bff3fb590dc33d5fdffc66293526859bba98f2

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module DispatchRider
  class Publisher::Configuration
    def initialize(configuration_hash = {})
      @notification_services = []
      @destinations = []
      parse(configuration_hash)
    end

    def notification_services
      @notification_services
    end

    def destinations
      @destinations
    end

    def parse(configuration_hash)
      clear

      configuration_hash = configuration_hash.with_indifferent_access
      configure_notification_services(configuration_hash[:notification_services] || {})
      configure_destinations(configuration_hash[:destinations] || {})
    end

    def clear
      @notification_services.clear
      @destinations.clear
    end

    private

    def configure_notification_services(notification_services_hash)
      notification_services_hash.each do |name, options|
        @notification_services << NotificationService.new(name, options)
      end
    end

    def configure_destinations(destinations_hash)
      destinations_hash.each do |name, options|
        @destinations << Destination.new(name, options)
      end
    end
  end
end

require_relative "configuration/destination"
require_relative "configuration/notification_service"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dispatch-rider-2.2.0 lib/dispatch-rider/publisher/configuration.rb