Sha256: 73af20a5b85db34e786309876c2aa82b0fdfce08ee27b6fb9e88c494ef4886b1

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 Bytes

Contents

module RockConfig
  class Manager
    def initialize(configuration, scanner = Scanner)
      @scanner = scanner.new(configuration)
      @configs = initialize_configs
    end

    def fetch(config_name, environment)
      if config = @configs[config_name]
        if config_for_environment = config[environment]
          return config_for_environment
        else
          raise EnvironmentNotFoundError, 
            'Environment "%s" not found' % environment
        end
      end
    end

    def initialize_configs
      Hash.new do |hash, key|
        if config = @scanner.find(key)
          hash[key] = config
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rock_config-0.0.4 lib/rock_config/manager.rb