Class: B1Config::Loader
- Inherits:
-
Object
- Object
- B1Config::Loader
- Defined in:
- lib/b1_config/loader.rb
Class Method Summary collapse
-
.load(load_paths) ⇒ Object
Load yaml files from directories and set it contains as options.
Class Method Details
.load(load_paths) ⇒ Object
Load yaml files from directories and set it contains as options
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/b1_config/loader.rb', line 4 def self.load load_paths load_paths.each do |path| raise B1Config::Exception.new(4,{path: path}) unless File.directory?(path) Dir.glob("#{path}*").each do |file| data = YAML::load(ERB.new(IO.read(File.open(file))).result) raise B1Config::Exception.new(3,{env:B1Config.env}) unless data.kind_of?(Hash) && data.has_key?(B1Config.env) B1Config::Options.update_data data[B1Config.env] end end end |