Module: DotConfig
- Defined in:
- lib/dot_config.rb,
lib/dot_config/version.rb,
lib/dot_config/configuration.rb
Overview
This module provides a way to define a set of configuration with read access only.
Defined Under Namespace
Modules: Version Classes: Configuration
Class Method Summary collapse
-
.new(config, writing = false) ⇒ Configuration
Returns an instance of
Configuration
.
Class Method Details
.new(config, writing = false) ⇒ Configuration
Returns an instance of Configuration
.
25 26 27 28 29 30 31 32 33 |
# File 'lib/dot_config.rb', line 25 def self.new(config, writing = false) if config.is_a?(Hash) Configuration.new(config: config, writing: writing) elsif config.is_a?(String) && File.exists?(config) Configuration.new(config: YAML.load(File.read(config)), writing: writing) else raise ArgumentError, 'Unable to process the config argument' end end |