Sha256: efdff8101620beab5795aff39f2d8f80a1103072fec44522fcd166c2f99e2a50
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 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, **) value end def referenced_model_classes EMPTY_ARRAY end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
avromatic-2.2.4 | lib/avromatic/model/types/string_type.rb |
avromatic-2.2.3 | lib/avromatic/model/types/string_type.rb |
avromatic-2.2.2 | lib/avromatic/model/types/string_type.rb |