Sha256: b39e9106b97c7eea71db78b5fccca7c20403ff4c6971d93dc68075dc6a1a7f3a
Contents?: true
Size: 610 Bytes
Versions: 11
Compression:
Stored size: 610 Bytes
Contents
# typed: strict module Typed module Coercion class StringCoercer < Coercer extend T::Generic Target = type_member { {fixed: String} } sig { override.params(type: T::Types::Base).returns(T::Boolean) } def used_for_type?(type) type == T::Utils.coerce(String) end sig { override.params(type: T::Types::Base, value: Value).returns(Result[Target, CoercionError]) } def coerce(type:, value:) return Failure.new(CoercionError.new("Type must be a String.")) unless used_for_type?(type) Success.new(String(value)) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems