Class: StaticConfig::Configurer
- Inherits:
-
Object
- Object
- StaticConfig::Configurer
- Defined in:
- lib/static_config/configurer.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #add(reader) ⇒ Object
- #build ⇒ Object
- #env(var_prefix) ⇒ Object
- #env_yaml(var_name) ⇒ Object
- #file(path, opts = {}) ⇒ Object
- #first(&block) ⇒ Object
- #push_readers ⇒ Object
Instance Attribute Details
#readers ⇒ Object
37 38 39 |
# File 'lib/static_config/configurer.rb', line 37 def readers @readers ||= [] end |
Instance Method Details
#add(reader) ⇒ Object
28 29 30 |
# File 'lib/static_config/configurer.rb', line 28 def add(reader) readers << reader end |
#build ⇒ Object
10 11 12 |
# File 'lib/static_config/configurer.rb', line 10 def build ConfigProxy.new StaticConfig::Aggregation::Merge.new(self.readers) end |
#env(var_prefix) ⇒ Object
19 20 21 |
# File 'lib/static_config/configurer.rb', line 19 def env(var_prefix) add StaticConfig::Reader::Environment.new(:env_prefix => var_prefix) end |
#env_yaml(var_name) ⇒ Object
22 23 24 |
# File 'lib/static_config/configurer.rb', line 22 def env_yaml(var_name) add StaticConfig::Reader::YamlEnv.new(:env => var_name) end |
#file(path, opts = {}) ⇒ Object
25 26 27 |
# File 'lib/static_config/configurer.rb', line 25 def file(path, opts={}) add StaticConfig::Reader::YamlFile.new(opts.merge(:file => path)) end |
#first(&block) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/static_config/configurer.rb', line 13 def first(&block) push_readers do instance_eval(&block) add StaticConfig::Aggregation::First.new self.readers end end |
#push_readers ⇒ Object
31 32 33 34 35 36 |
# File 'lib/static_config/configurer.rb', line 31 def push_readers old_readers, self.readers = self.readers, [] yield ensure self.readers = old_readers end |