Class: By2::ConfigLoader
- Inherits:
-
Object
- Object
- By2::ConfigLoader
- Defined in:
- lib/by2/config_loader.rb
Instance Attribute Summary collapse
-
#search_paths ⇒ Object
Returns the value of attribute search_paths.
Instance Method Summary collapse
-
#initialize ⇒ ConfigLoader
constructor
A new instance of ConfigLoader.
- #load(config_file, required = false) ⇒ Object
Constructor Details
#initialize ⇒ ConfigLoader
Returns a new instance of ConfigLoader.
5 6 7 |
# File 'lib/by2/config_loader.rb', line 5 def initialize @search_paths ||= [app_config, user_config] end |
Instance Attribute Details
#search_paths ⇒ Object
Returns the value of attribute search_paths.
3 4 5 |
# File 'lib/by2/config_loader.rb', line 3 def search_paths @search_paths end |
Instance Method Details
#load(config_file, required = false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/by2/config_loader.rb', line 9 def load(config_file, required = false) search_paths.each do |path| file = File.(File.join(path, config_file)) By2.debug("Searching for #{file} in #{path}") if File.exists?(file) By2.debug("Loaded: #{file}") return YAML.load_file(file) end end By2.debug("Could not load: #{config_file}") required ? raise : nil end |