From bf390163aa7f282737d8ca1f4c9599077b6d518f Mon Sep 17 00:00:00 2001 From: Erik Ordway Date: Tue, 19 Nov 2013 11:43:01 -0800 Subject: [PATCH] Load plugin settings. Along the lines for loading the locale files for a plugin we should also load the settings.yml for a plugin. Updated version 04f3e09 that moves the loading to a function. I do not understand why it was necessary to define the function physically earlier in the file as I thought ruby did two pass but that may only apply to functions and not stray code in the class. --- app/models/site_setting.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index d78d18c0274..80b330f359b 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -7,14 +7,23 @@ class SiteSetting < ActiveRecord::Base validates_presence_of :name validates_presence_of :data_type - SiteSettings::YamlLoader.new( File.join( Rails.root, 'config', 'site_settings.yml') ).load do |category, name, default, opts| - if opts.delete(:client) - client_setting(name, default, opts.merge(category: category)) - else - setting(name, default, opts.merge(category: category)) + def self.load_settings(file) + SiteSettings::YamlLoader.new(file).load do |category, name, default, opts| + if opts.delete(:client) + client_setting(name, default, opts.merge(category: category)) + else + setting(name, default, opts.merge(category: category)) + end end end + load_settings(File.join(Rails.root, 'config', 'site_settings.yml')) + + Dir[File.join(Rails.root, "plugins", "*", "config", "settings.yml")].each do |file| + load_settings(file) + end + + def self.call_discourse_hub? self.enforce_global_nicknames? && self.discourse_org_access_key.present? end