Sha256: 97059ce3b37d0ff93908d9f01ecd15a9a8965c9c367b13770a12ac562e895a05

Contents?: true

Size: 643 Bytes

Versions: 41

Compression:

Stored size: 643 Bytes

Contents

module ComplexConfig
  Config = Struct.new('Config', :config_dir, :env, :deep_freeze, :plugins) do
    def initialize(*)
      super
      self.plugins = []
    end

    def configure(provider)
      each_pair do |name, value|
        value.nil? and next
        name == :plugins and next
        provider.__send__("#{name}=", value)
      end
      plugins.each do |code|
        provider.add_plugin(code)
      end
      self
    end

    def add_plugin(code)
      plugins << code
      self
    end
  end

  def self.configure
    config = Config.new
    yield config
    ComplexConfig::Provider.configure_with config
    config
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
complex_config-0.22.2 lib/complex_config/config.rb
complex_config-0.22.1 lib/complex_config/config.rb
complex_config-0.22.0 lib/complex_config/config.rb
complex_config-0.21.2 lib/complex_config/config.rb
complex_config-0.21.1 lib/complex_config/config.rb
complex_config-0.21.0 lib/complex_config/config.rb
complex_config-0.20.0 lib/complex_config/config.rb
complex_config-0.19.4 lib/complex_config/config.rb
complex_config-0.19.3 lib/complex_config/config.rb
complex_config-0.19.2 lib/complex_config/config.rb
complex_config-0.19.1 lib/complex_config/config.rb
complex_config-0.19.0 lib/complex_config/config.rb
complex_config-0.18.2 lib/complex_config/config.rb
complex_config-0.18.1 lib/complex_config/config.rb
complex_config-0.18.0 lib/complex_config/config.rb
complex_config-0.17.1 lib/complex_config/config.rb
complex_config-0.17.0 lib/complex_config/config.rb
complex_config-0.16.0 lib/complex_config/config.rb
complex_config-0.15.1 lib/complex_config/config.rb
complex_config-0.15.0 lib/complex_config/config.rb