Welcome to mirror list, hosted at ThFree Co, Russian Federation.

settings.rb « gitlab_settings « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 79d006fb11809989ac8374a88ffdb7c46fccc630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

module GitlabSettings
  class Settings
    attr_reader :source

    def initialize(source, section)
      raise(ArgumentError, 'config source is required') if source.blank?
      raise(ArgumentError, 'config section is required') if section.blank?

      @source = source
      @section = section

      reload!
    end

    def reload!
      yaml = ActiveSupport::ConfigurationFile.parse(source)
      all_configs = yaml.deep_stringify_keys
      configs = all_configs[section]

      @config = Options.build(configs)
    end

    def method_missing(name, *args)
      config.public_send(name, *args) # rubocop: disable GitlabSecurity/PublicSend
    end

    def respond_to_missing?(name, include_all = false)
      config.respond_to?(name, include_all)
    end

    private

    attr_reader :config, :section
  end
end