Class: Configru::Config
- Inherits:
-
StructHash
- Object
- Hash
- StructHash
- Configru::Config
- Defined in:
- lib/configru/config.rb
Instance Method Summary collapse
-
#initialize(*files, &block) ⇒ Config
constructor
A new instance of Config.
- #reload ⇒ Object
Methods inherited from StructHash
Constructor Details
#initialize(*files, &block) ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 |
# File 'lib/configru/config.rb', line 7 def initialize(*files, &block) @files = files.flatten @dsl_block = block reload end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Configru::StructHash
Instance Method Details
#reload ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/configru/config.rb', line 13 def reload @options = DSL::OptionGroup.new(&@dsl_block). loaded_files = Array.new @files.each do |file| if File.file?(file) && !File.zero?(file) load_file(file) loaded_files << file end end # Load all defaults if no files were loaded # TODO: Some way to not special case this @option_path = Array.new @file = '(none)' load_group(@options, self, {}) if loaded_files.empty? end |