Class: DiscourseDev::Config
- Inherits:
-
Object
- Object
- DiscourseDev::Config
- Defined in:
- lib/discourse_dev/config.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #update! ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/discourse_dev/config.rb', line 10 def initialize default_file_path = File.join(Rails.root, "config", "dev_defaults.yml") @file_path = File.join(Rails.root, "config", "dev.yml") # https://stackoverflow.com/questions/71332602/upgrading-to-ruby-3-1-causes-psychdisallowedclass-exception-when-using-yaml-lo default_config = YAML.load_file(default_file_path, permitted_classes: [Date]) if File.exist?(file_path) user_config = YAML.load_file(file_path, permitted_classes: [Date]) else puts "Did not detect `config/dev.yml`, creating one for you where you can amend defaults." FileUtils.cp(default_file_path, file_path) user_config = {} end @config = default_config.deep_merge(user_config).deep_symbolize_keys end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object (private)
86 87 88 |
# File 'lib/discourse_dev/config.rb', line 86 def method_missing(name) config[name.to_sym] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/discourse_dev/config.rb', line 8 def config @config end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
8 9 10 |
# File 'lib/discourse_dev/config.rb', line 8 def file_path @file_path end |
Instance Method Details
#update! ⇒ Object
27 28 29 30 31 32 |
# File 'lib/discourse_dev/config.rb', line 27 def update! update_site_settings create_admin_user create_new_user set_seed end |