Class: Kangaru::Config
- Inherits:
-
Object
- Object
- Kangaru::Config
- Defined in:
- lib/kangaru/config.rb
Instance Attribute Summary collapse
-
#configurators ⇒ Object
readonly
Returns the value of attribute configurators.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #errors ⇒ Object
- #import!(path) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #serialise ⇒ Object
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
7 8 9 |
# File 'lib/kangaru/config.rb', line 7 def initialize @configurators = set_configurators! end |
Instance Attribute Details
#configurators ⇒ Object (readonly)
Returns the value of attribute configurators.
5 6 7 |
# File 'lib/kangaru/config.rb', line 5 def configurators @configurators end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 |
# File 'lib/kangaru/config.rb', line 21 def [](key) configurators[key.to_sym] end |
#errors ⇒ Object
34 35 36 |
# File 'lib/kangaru/config.rb', line 34 def errors configurators.values.flat_map(&:errors) end |
#import!(path) ⇒ Object
11 12 13 14 15 |
# File 'lib/kangaru/config.rb', line 11 def import!(path) read_external_config(path).each do |key, config| configurators[key]&.merge!(**config) end end |
#serialise ⇒ Object
17 18 19 |
# File 'lib/kangaru/config.rb', line 17 def serialise configurators.transform_values(&:serialise) end |
#valid? ⇒ Boolean
25 26 27 28 |
# File 'lib/kangaru/config.rb', line 25 def valid? validate errors.empty? end |
#validate ⇒ Object
30 31 32 |
# File 'lib/kangaru/config.rb', line 30 def validate configurators.each_value(&:validate) end |