Class: Ballast::Configuration
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- Ballast::Configuration
- Defined in:
- lib/ballast/configuration.rb
Overview
A class which loads a list of YAML files in a folder and expose them in a dotted notation. For each file, only the subsection for the current environment is loaded, so each YAML document should be an hash.
Instance Method Summary (collapse)
-
- (Configuration) initialize(sections: [], root: nil, environment: nil)
constructor
Creates a new configuration.
Constructor Details
- (Configuration) initialize(sections: [], root: nil, environment: nil)
Creates a new configuration.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ballast/configuration.rb', line 16 def initialize(sections: [], root: nil, environment: nil) super() root ||= Rails.root.to_s environment ||= Rails.env sections.each do |section| content = (YAML.load_file("#{root}/config/#{section}.yml") rescue {}).with_indifferent_access self[section] = content[environment] end self.enable_dotted_access end |