Module: Modern::Types

Defined in:
lib/modern/types.rb

Constant Summary collapse

HTTP_METHODS =

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…

%w[GET POST PUT DELETE PATCH HEAD OPTIONS TRACE]
Type =

rubocop:enable Style/MutableConstant

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)

Class Method Summary collapse

Class Method Details

.array_of(type) ⇒ Object



37
38
39
# File 'lib/modern/types.rb', line 37

def self.array_of(type)
  Modern::Types::Strict::Array.of(type).default([])
end