module Dry::Types::Constructor::Wrapper
def __new__(type) = self.class.new(type, *@__args__.drop(1), **@options)
- Api: - private
def __new__(type) = self.class.new(type, *@__args__.drop(1), **@options)
def call_safe(input, &) = fn.(input, type, &)
- Api: - private
Returns:
-
(Object)
-
def call_safe(input, &) = fn.(input, type, &)
def call_unsafe(input) = fn.(input, type)
- Api: - private
Returns:
-
(Object)
-
def call_unsafe(input) = fn.(input, type)
def lax
- Api: - public
Returns:
-
(Constructor)
-
def lax # return self back because wrapping function # can handle failed type check self end
def prepend(new_fn = nil, **options, &block)
- Api: - public
Returns:
-
(Constructor)
-
Parameters:
-
block
(#call, nil
) -- -
options
(Hash
) -- -
new_fn
(#call, nil
) --
def prepend(new_fn = nil, **options, &block) prep_fn = Function[new_fn || block] decorated = if prep_fn.wrapper? type.constructor(prep_fn, **options) else type.prepend(prep_fn, **options) end __new__(decorated) end
def try(input, &)
- Api: - public
Returns:
-
(Object)
- if block given and try fails -
(Logic::Result, Types::Result)
-
Parameters:
-
block
(#call, nil
) -- -
input
(Object
) --
def try(input, &) value = fn.(input, type) rescue CoercionError => e failure = failure(input, e) block_given? ? yield(failure) : failure else type.try(value, &) end