Sha256: 6ef4979d35cda865bdaca92a6afd4632a32ae0e6e71e6f57593d4fcdf073d141

Contents?: true

Size: 1.17 KB

Versions: 55

Compression:

Stored size: 1.17 KB

Contents

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

55 entries across 55 versions & 1 rubygems

Version Path
dispatch-rider-1.9.0 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.8.6 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.8.5 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.8.4 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.8.3 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.8.2 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.8.1 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.8.0 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.7.2 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.7.1 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.7.0 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.6.2 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.6.1 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.6.0 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.5.3 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.5.2 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.5.1 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.5.0 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.4.2 lib/dispatch-rider/publisher/configuration.rb
dispatch-rider-1.4.0 lib/dispatch-rider/publisher/configuration.rb