Module: ConfigSL::FromFile::ClassMethods
- Defined in:
- lib/configsl/from_file.rb
Overview
Required class methods for loading config files.
Instance Method Summary collapse
-
#from_file(path = nil, format: nil) ⇒ self
Loads configuration from a file.
Instance Method Details
#from_file(path = nil, format: nil) ⇒ self
Loads configuration from a file.
If no path is specified, uses the file file that matches the default path, name, and file formats. If multiple files are found, they will be sorted based on the order the file formats are defined, adn the first file will be load.
48 49 50 51 52 53 |
# File 'lib/configsl/from_file.rb', line 48 def from_file(path = nil, format: nil) path ||= find_file.first format ||= find_file_format(File.extname(path)) file = @config_file_formats[format][:class].new(path) new(file.read) end |