Sha256: 66738dcc3c7ee0479f7f7506e42abaa8ca07f3ea5f67c3638e11b46a0424719c
Contents?: true
Size: 1.61 KB
Versions: 10
Compression:
Stored size: 1.61 KB
Contents
require 'dry/types/hash/schema' module Dry module Types class Hash < Definition # @param [{Symbol => Definition}] type_map # @param [Class] klass # {Schema} or one of its subclasses ({Weak}, {Permissive}, {Strict}, # {StrictWithDefaults}, {Symbolized}) # @return [Schema] def schema(type_map, klass = Schema) member_types = type_map.each_with_object({}) { |(name, type), result| result[name] = case type when String, Class then Types[type] else type end } klass.new(primitive, options.merge(member_types: member_types, meta: meta)) end # @param [{Symbol => Definition}] type_map # @return [Weak] def weak(type_map) schema(type_map, Weak) end # @param [{Symbol => Definition}] type_map # @return [Permissive] def permissive(type_map) schema(type_map, Permissive) end # @param [{Symbol => Definition}] type_map # @return [Strict] def strict(type_map) schema(type_map, Strict) end # @param [{Symbol => Definition}] type_map # @return [StrictWithDefaults] def strict_with_defaults(type_map) schema(type_map, StrictWithDefaults) end # @param [{Symbol => Definition}] type_map # @return [Symbolized] def symbolized(type_map) schema(type_map, Symbolized) end private # @param [Hash] _result # @param [Symbol] _key # @param [Type] _type def resolve_missing_value(_result, _key, _type) # noop end end end end
Version data entries
10 entries across 10 versions & 1 rubygems