class Necromancer::ArrayConverters::StringToArrayConverter
An object that converts a String to an Array
Public Instance Methods
call(value, strict: config.strict)
click to toggle source
Convert string value to array
@example
converter.call("a, b, c") # => ["a", "b", "c"]
@example
converter.call("1 - 2 - 3") # => ["1", "2", "3"]
@api public
# File lib/necromancer/converters/array.rb, line 25 def call(value, strict: config.strict) return [] if value.to_s.empty? if match = value.to_s.match(ARRAY_MATCHER) value.to_s.split(match[:sep]) else strict ? raise_conversion_type(value) : Array(value) end end