Class: EnvironmentConfig::Types::Boolean

Inherits:
Object
  • Object
show all
Defined in:
lib/environment_config/types/boolean.rb

Constant Summary collapse

BOOLEAN_VALUES =
%w[true false].freeze

Class Method Summary collapse

Class Method Details

.convert(value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/environment_config/types/boolean.rb', line 13

def convert(value)
  # ensure compatibility when receiving correctly typed default value
  value = value.to_s

  unless BOOLEAN_VALUES.include?(value)
    raise TypeError.new(BOOLEAN_VALUES.join('/'), value)
  end

  value == 'true'
end

.nameObject



9
10
11
# File 'lib/environment_config/types/boolean.rb', line 9

def name
  :boolean
end