Class: Gitlab::Config::Loader::Yaml
Constant Summary
collapse
- DataTooLargeError =
Class.new(Loader::FormatError)
- NotHashError =
Class.new(Loader::FormatError)
Instance Method Summary
collapse
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(config, additional_permitted_classes: []) ⇒ Yaml
Returns a new instance of Yaml.
12
13
14
15
16
17
18
19
20
|
# File 'lib/gitlab/config/loader/yaml.rb', line 12
def initialize(config, additional_permitted_classes: [])
@config = YAML.safe_load(config,
permitted_classes: [Symbol, *additional_permitted_classes],
permitted_symbols: [],
aliases: true
)
rescue Psych::Exception => e
raise Loader::FormatError, e.message
end
|
Instance Method Details
#load! ⇒ Object
33
34
35
|
# File 'lib/gitlab/config/loader/yaml.rb', line 33
def load!
@symbolized_config ||= load_raw!.deep_symbolize_keys
end
|
#load_raw! ⇒ Object
26
27
28
29
30
31
|
# File 'lib/gitlab/config/loader/yaml.rb', line 26
def load_raw!
raise DataTooLargeError, 'The parsed YAML is too big' if too_big?
raise NotHashError, 'Invalid configuration format' unless hash?
@config
end
|
#valid? ⇒ Boolean
22
23
24
|
# File 'lib/gitlab/config/loader/yaml.rb', line 22
def valid?
hash? && !too_big?
end
|