Class: IncludeWithRespect::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/include_with_respect/configuration.rb

Constant Summary collapse

VALID_LEVELS =
%i[warning error skip silent]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Configuration

Returns a new instance of Configuration.



8
9
10
11
# File 'lib/include_with_respect/configuration.rb', line 8

def initialize(**options)
  self.level = options[:level] || :warning
  validate
end

Instance Attribute Details

#levelObject

Returns the value of attribute level.



6
7
8
# File 'lib/include_with_respect/configuration.rb', line 6

def level
  @level
end

Instance Method Details

#validateObject



17
18
19
20
21
22
# File 'lib/include_with_respect/configuration.rb', line 17

def validate
  unexpected = (level - VALID_LEVELS)
  return unless unexpected.any?

  raise ::IncludeWithRespect::Error, "Unexpected configuration value(s) for level: #{unexpected}"
end