Sha256: 6e3d044717f7e3094c09f5dafa0611814985279eab901ff210d610a0c5575564

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 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.send(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

2 entries across 2 versions & 1 rubygems

Version Path
rock_config-0.0.3 lib/rock_config/manager.rb
rock_config-0.0.2 lib/rock_config/manager.rb