Class: BlendedConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/blended_config.rb,
lib/blended_config/source.rb,
lib/blended_config/version.rb,
lib/blended_config/option_group.rb,
lib/blended_config/sources/file.rb,
lib/blended_config/option_resolver.rb,
lib/blended_config/sources/environment.rb,
lib/blended_config/sources/toml_source.rb

Defined Under Namespace

Modules: Sources Classes: OptionGroup, OptionResolver, Source

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env: ENV, **options) ⇒ BlendedConfig

Returns a new instance of BlendedConfig.



30
31
32
33
# File 'lib/blended_config.rb', line 30

def initialize(env: ENV, **options)
  bind_config_file(options)
  bind_environment(env)
end

Class Method Details

.group(name, &options) ⇒ Object



8
9
10
11
12
13
# File 'lib/blended_config.rb', line 8

def self.group(name, &options)
  option_group = OptionGroup.new(name, &options)
  option_groups << option_group

  define_method(name) { option_group }
end

.option(name, &resolution) ⇒ Object



15
16
17
18
19
20
# File 'lib/blended_config.rb', line 15

def self.option(name, &resolution)
  option_resolver = OptionResolver.new(name, &resolution)
  option_resolvers << option_resolver

  define_method(name) { option_resolver }
end

.option_groupsObject



22
23
24
# File 'lib/blended_config.rb', line 22

def self.option_groups
  @option_groups ||= []
end

.option_resolversObject



26
27
28
# File 'lib/blended_config.rb', line 26

def self.option_resolvers
  @option_resolvers ||= []
end