Class: Rain::ConfigLoader
- Inherits:
-
Object
- Object
- Rain::ConfigLoader
- Defined in:
- lib/support/config_loader.rb
Class Method Summary collapse
Class Method Details
.load(filepath, overrides = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/support/config_loader.rb', line 9 def load(filepath, overrides = {}) config_file = YAML.safe_load_file(filepath, permitted_classes: [Symbol], symbolize_names: true) # Environment variables override config file. config_data = config_file.merge(overrides) do |_key, old_value, new_value| new_value.nil? ? old_value : new_value end OpenStruct.new(config_data) end |
.parse_boolean(value) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/support/config_loader.rb', line 20 def parse_boolean(value) return true if value == '1' return false if value == '0' nil end |