Sha256: 40e8c9331e63520f4c05570774a116e1b4d6f0fe5b3f6d6bf19f99ba8cc893c7
Contents?: true
Size: 799 Bytes
Versions: 5
Compression:
Stored size: 799 Bytes
Contents
InputSanitizer::V1::CleanField = MethodStruct.new(:data, :has_key, :converter, :required, :collection, :namespace, :default, :provide, :allow) do def call if has_key convert elsif default converter.call(default) elsif required raise InputSanitizer::ValueMissingError else raise InputSanitizer::OptionalValueOmitted end end private def convert if collection data.map { |value| convert_single(value) } else convert_single(data) end end def convert_single(value) if namespace { namespace => convert_value(value[namespace]) } else convert_value(value) end end def convert_value(value) if provide converter.call(value, provide) else converter.call(value) end end end
Version data entries
5 entries across 5 versions & 1 rubygems