Class: Contur::Config::Use

Inherits:
Hash
  • Object
show all
Defined in:
lib/contur/config/use.rb

Overview

Use section

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(using = {}) ⇒ Use

Returns a new instance of Use.



16
17
18
19
20
21
22
23
# File 'lib/contur/config/use.rb', line 16

def initialize(using = {})
  super
  replace(DEFAULTS)

  validate!(using)

  merge!(using) unless using.nil?
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



34
35
36
# File 'lib/contur/config/use.rb', line 34

def errors
  @errors
end

Instance Method Details

#nameObject



36
37
38
# File 'lib/contur/config/use.rb', line 36

def name
  "Section 'use'"
end

#validate!(using) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/contur/config/use.rb', line 25

def validate!(using)
  @errors = []
  return unless using.respond_to? :keys
  extra_keys = using.keys - ALLOWED_VALUES
  extra_keys.each do |key|
    @errors << "Unknown key: #{key}"
  end
end