Module: ConfigSL::FromFile
- Included in:
- Config
- Defined in:
- lib/configsl/from_file.rb
Overview
Load configuration from a file.
This module provides a way to load configuration values from a file. It searches for files based on a default path, name, and one or more file formats.
When multiple files are found, they will be sorted based on the order their formats are defined, and the first file will be loaded.
For example:
config_file_path 'config'
config_file_name 'config'
register_file_format :yaml
register_file_format :json
will search for files in the ‘config` directory, with the name `config`, and with the extensions `.yaml`, `.yml` and `.json`. If both `config.yaml` and `config.json` are found, `config.yaml` will be loaded.
This module depends on the ‘FileSupport` module and will it include it your class if it has not been so already.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
30 31 32 33 |
# File 'lib/configsl/from_file.rb', line 30 def self.included(base) base.include(FileSupport) unless base.include?(FileSupport) base.extend(ClassMethods) end |