Module: AuConfig
- Defined in:
- lib/admin-utils/au_config.rb
Instance Method Summary collapse
-
#load_config(config_file, override_path = nil) ⇒ Object
Method that loads a yml file and return an object of type
OpenStruct
.
Instance Method Details
#load_config(config_file, override_path = nil) ⇒ Object
Method that loads a yml file and return an object of type OpenStruct
Params:
-
config_file
Name of the config file to load -
override_path
Path to the directory that contains the yml file. If left blank, the default is taken which is configured inAuDefaults
‘sCONFIG_PATH
array. Can be either an array of path names or a single path as a string
If override_path
is an array (e.g. when using the default), the first occurrence of the config file ist loaded.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/admin-utils/au_config.rb', line 15 def load_config(config_file, override_path = nil) raise ArgumentError 'Plain config file name needed as string!' unless config_file @config_path = AuDefaults.config_path override_path begin @configuration = get_config_file_for_path(@config_path, config_file) logger.debug 'Using Config File: ' + @configuration.path @yml_data = YAML.load @configuration AuUtil.hash_to_ostruct @yml_data.merge(_config_file: @configuration.path) rescue => error logger.error "Error opening file #{@configuration}. The Message was: #{error.}\n#{error.backtrace.join("\n")}" raise end end |