Sha256: 47615cfb1c8fa305bfb28a86fd58f27e9bfe0e29eb2f67b2ccb7304e56cf863e

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

require 'axel/configurations/service'
module Axel
  module Configurators
    class Services
      attr_reader :services
      def initialize
        @services = {}.with_indifferent_access
      end

      def resources
        services.values.collect(&:resources).inject({}.with_indifferent_access) { |hash, pair| hash.merge pair }
      end

      def add_service(service_name, url)
        if services[service_name]
          services[service_name].url = url if url
          services[service_name]
        else
          services[service_name] = Configurations::Service.new(service_name, url)
        end
      end

      def add_resource(service_name, resource_name, options = {})
        service = add_service service_name, (options.delete(:service) || {})[:url]
        service.add_resource resource_name, options
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axel-0.0.1 lib/axel/configurators/services.rb