Sha256: b4d62efe74273606a839d4c14600b39af3eddbe117ac7075a4723c4795241a5e
Contents?: true
Size: 1.06 KB
Versions: 14
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true require 'avromatic/model/types/abstract_type' module Avromatic module Model module Types class StringType < AbstractType VALUE_CLASSES = [::String].freeze INPUT_CLASSES = [::String, ::Symbol].freeze def value_classes VALUE_CLASSES end def input_classes INPUT_CLASSES end def name 'string' end def coerce(input) if input.nil? || input.is_a?(::String) input elsif input.is_a?(::Symbol) input.to_s else raise ArgumentError.new("Could not coerce '#{input.inspect}' to #{name}") end end def coercible?(input) input.nil? || input.is_a?(::String) || input.is_a?(::Symbol) end def coerced?(value) value.nil? || value.is_a?(::String) end def serialize(value, _strict) value end def referenced_model_classes EMPTY_ARRAY end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems