Class: RailsConfig::Options
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- RailsConfig::Options
- Defined in:
- lib/rails_config/options.rb
Instance Method Summary collapse
- #add_source!(source) ⇒ Object
- #empty? ⇒ Boolean
-
#reload! ⇒ Object
(also: #load!)
look through all our sources and rebuild the configuration.
- #reload_from_files(*files) ⇒ Object
Instance Method Details
#add_source!(source) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rails_config/options.rb', line 9 def add_source!(source) # handle yaml file paths source = (Sources::YAMLSource.new(source)) if source.is_a?(String) @config_sources ||= [] @config_sources << source end |
#empty? ⇒ Boolean
5 6 7 |
# File 'lib/rails_config/options.rb', line 5 def empty? marshal_dump.empty? end |
#reload! ⇒ Object Also known as: load!
look through all our sources and rebuild the configuration
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails_config/options.rb', line 18 def reload! conf = {} @config_sources.each do |source| source_conf = source.load if conf.empty? conf = source_conf else DeepMerge.deep_merge!(source_conf, conf, :preserve_unmergeables => false) end end # swap out the contents of the OStruct with a hash (need to recursively convert) marshal_load(__convert(conf).marshal_dump) return self end |
#reload_from_files(*files) ⇒ Object
38 39 40 41 |
# File 'lib/rails_config/options.rb', line 38 def reload_from_files(*files) RailsConfig.load_and_set_settings(files) reload! end |