Class: Necromancer::ArrayConverters::StringToBooleanArrayConverter

Inherits:
Converter
  • Object
show all
Defined in:
lib/necromancer/converters/array.rb

Instance Attribute Summary

Attributes inherited from Converter

#config, #convert, #source, #target

Instance Method Summary collapse

Methods inherited from Converter

create, #initialize, #raise_conversion_type

Constructor Details

This class inherits a constructor from Necromancer::Converter

Instance Method Details

#call(value, strict: config.strict) ⇒ Object

Examples:

converter.call("t,f,yes,no") # => [true, false, true, false]

Parameters:

  • value (Array)

    the array value to boolean



44
45
46
47
48
49
# File 'lib/necromancer/converters/array.rb', line 44

def call(value, strict: config.strict)
  array_converter = StringToArrayConverter.new(:string, :array)
  array = array_converter.(value, strict: strict)
  bool_converter = ArrayToBooleanArrayConverter.new(:array, :boolean)
  bool_converter.(array, strict: strict)
end