Sha256: 6222d0cea1d0b1bee3ac6492b543091bc42c193d16fec4d1cb042c689328bcbb
Contents?: true
Size: 479 Bytes
Versions: 5
Compression:
Stored size: 479 Bytes
Contents
module InputSanitizer class SpecificValuesConverter def initialize(values) @valid_values = values end def call(value) case when @valid_values.include?(value) value when value.respond_to?(:to_sym) && @valid_values.include?(value.to_sym) value.to_sym else values_joined = @valid_values.join(", ") raise InputSanitizer::ConversionError.new("Possible values: #{values_joined}") end end end end
Version data entries
5 entries across 5 versions & 1 rubygems