Sha256: 087a423d0c82078ebb02a6423aef3d8ea84e0e4b76b991f39147058c2fd391e7
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require 'dry/types' require 'dry/struct' require 'ice_nine' module Modern module Types include Dry::Types.module # rubocop:disable Style/MutableConstant # This is left unfrozen so as to allow additional verbs to be added # in the future. Should be rare, but I've seen it done... HTTP_METHODS = %w[GET POST PUT DELETE PATCH HEAD OPTIONS TRACE] # rubocop:enable Style/MutableConstant Type = Instance(Dry::Types::Type) Struct = Instance(Dry::Struct) HttpMethod = Types::Coercible::String.enum(*HTTP_METHODS) HttpPath = Types::Strict::String.constrained( format: %r,/.*, ) MIMEType = Types::Strict::String.constrained( format: %r,\w+/[-.\w]+(?:\+[-.\w]+)?, ) RouteAction = Instance(Proc) SecurityAction = Instance(Proc) ParameterStyle = Types::Coercible::String.enum(:matrix, :label, :form, :simple, :space_delimited, :pipe_delimited, :deep_object) def self.array_of(type) Modern::Types::Strict::Array.of(type).default([]) end end end
Version data entries
6 entries across 6 versions & 1 rubygems