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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/discourse_dev/config.rb', line 10 def initialize default_file_path = File.join(DiscourseDev.root, "config", "dev.yml") @file_path = File.join(Rails.root, "config", "dev.yml") default_config = YAML.load_file(default_file_path) if File.exists?(file_path) user_config = YAML.load_file(file_path) else puts "I did no detect a custom `config/dev.yml` file, 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)
84 85 86 |
# File 'lib/discourse_dev/config.rb', line 84 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
26 27 28 29 30 31 |
# File 'lib/discourse_dev/config.rb', line 26 def update! update_site_settings create_admin_user create_new_user set_seed end |