Sha256: 6088d75430b18a51b57582d1688b52603aa1e0d79879af767525e510307d2e73
Contents?: true
Size: 992 Bytes
Versions: 5
Compression:
Stored size: 992 Bytes
Contents
# frozen_string_literal: true require 'avromatic/model/types/abstract_type' module Avromatic module Model module Types class StringType 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 end end end end
Version data entries
5 entries across 5 versions & 1 rubygems