Module: Redmine::Configuration

Defined in:
lib/redmine/configuration.rb

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Returns a configuration setting


66
67
68
69
# File 'lib/redmine/configuration.rb', line 66

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)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/redmine/configuration.rb', line 34

def load(options={})
  filename = options[:file] || File.join(Rails.root, 'config', 'configuration.yml')
  env = options[: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|
      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


72
73
74
75
76
77
78
79
# File 'lib/redmine/configuration.rb', line 72

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