Module: Redmine::Configuration
- Defined in:
- lib/redmine/configuration.rb
Class Method Summary collapse
-
.[](name) ⇒ Object
Returns a configuration setting.
-
.load(options = {}) ⇒ Object
Loads the Redmine configuration file Valid options: *
:file
: the configuration file to load (default: config/configuration.yml) *:env
: the environment to load the configuration for (default: Rails.env). -
.with(settings) ⇒ Object
Yields a block with the specified hash configuration settings.
Class Method Details
.[](name) ⇒ Object
Returns a configuration setting
78 79 80 81 |
# File 'lib/redmine/configuration.rb', line 78 def [](name) load unless @config @config[name] end |
.load(options = {}) ⇒ Object
Loads the Redmine configuration file Valid options:
-
:file
: the configuration file to load (default: config/configuration.yml) -
:env
: the environment to load the configuration for (default: Rails.env)
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/redmine/configuration.rb', line 40 def load(={}) filename = [:file] || File.join(Rails.root, 'config', 'configuration.yml') env = [:env] || Rails.env @config = @defaults.dup load_deprecated_email_configuration(env) if File.file?(filename) @config.merge!(load_from_yaml(filename, env)) end # Compatibility mode for those who copy email.yml over configuration.yml %w(delivery_method smtp_settings sendmail_settings).each do |key| if value = @config.delete(key) @config['email_delivery'] ||= {} @config['email_delivery'][key] = value end end if @config['email_delivery'] ActionMailer::Base.perform_deliveries = true @config['email_delivery'].each do |k, v| # Comprehensive error message for those who used async_smtp and async_sendmail # delivery methods that are removed in Redmine 4.0. if k == 'delivery_method' && v.to_s =~ /\Aasync_(.+)/ abort "Redmine now uses ActiveJob to send emails asynchronously and the :#{v} delivery method is no longer available.\n" + "Please update your config/configuration.yml to use :#$1 delivery method instead." end v.symbolize_keys! if v.respond_to?(:symbolize_keys!) ActionMailer::Base.send(:"#{k}=", v) end end check_regular_expressions @config end |
.with(settings) ⇒ Object
Yields a block with the specified hash configuration settings
84 85 86 87 88 89 90 91 |
# File 'lib/redmine/configuration.rb', line 84 def with(settings) settings.stringify_keys! load unless @config was = settings.keys.inject({}) {|h, v| h[v] = @config[v]; h} @config.merge! settings yield if block_given? @config.merge! was end |