Sha256: 668f2d88d567386c8854ad57b90538921a37c05437bf71605caa5c9790557423
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
class StrongJSON module Types # @type method object: (?Hash<Symbol, ty>) -> Type::Object<any> def object(fields = {}) if fields.empty? Type::Object.new(fields, ignored_attributes: nil, prohibited_attributes: Set.new) else Type::Object.new(fields, ignored_attributes: :any, prohibited_attributes: Set.new) end end # @type method array: (?ty) -> Type::Array<any> def array(type = any) Type::Array.new(type) end # @type method optional: (?ty) -> Type::Optional<any> def optional(type = any) Type::Optional.new(type) end def string StrongJSON::Type::Base.new(:string) end def numeric StrongJSON::Type::Base.new(:numeric) end def number StrongJSON::Type::Base.new(:number) end def boolean StrongJSON::Type::Base.new(:boolean) end def any StrongJSON::Type::Base.new(:any) end def any? optional(any) end def symbol StrongJSON::Type::Base.new(:symbol) end def literal(value) StrongJSON::Type::Literal.new(value) end def enum(*types, detector: nil) StrongJSON::Type::Enum.new(types, detector) end def string? optional(string) end def numeric? optional(numeric) end def number? optional(number) end def boolean? optional(boolean) end def symbol? optional(symbol) end def array?(ty) optional(array(ty)) end # @type method object?: (?Hash<Symbol, ty>) -> Type::Optional<any> def object?(fields={}) optional(object(fields)) end def literal?(value) optional(literal(value)) end def enum?(*types, detector: nil) optional(enum(*types, detector: detector)) end def hash(type) StrongJSON::Type::Hash.new(type) end def hash?(type) optional(hash(type)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
strong_json-1.1.0 | lib/strong_json/types.rb |