class Dry::Types::Lax

Lax types rescue from type-related errors when constructors fail

@api public

Public Instance Methods

[](input)
Alias for: call
call(input) click to toggle source

@param [Object] input

@return [Object]

@api public

# File lib/dry/types/lax.rb, line 25
def call(input)
  type.call_safe(input) { |output = input| output }
end
Also aliased as: [], call_safe, call_unsafe
call_safe(input)
Alias for: call
call_unsafe(input)
Alias for: call
lax() click to toggle source

@return [Lax]

@api public

# File lib/dry/types/lax.rb, line 55
def lax
  self
end
to_ast(meta: true) click to toggle source

@see Nominal#to_ast

@api public

# File lib/dry/types/lax.rb, line 48
def to_ast(meta: true)
  [:lax, type.to_ast(meta: meta)]
end
try(input, &block) click to toggle source

@param [Object] input @param [#call,nil] block

@yieldparam [Failure] failure @yieldreturn [Result]

@return [Result,Logic::Result]

@api public

# File lib/dry/types/lax.rb, line 41
def try(input, &block)
  type.try(input, &block)
end

Private Instance Methods

decorate?(response) click to toggle source

@param [Object, Dry::Types::Constructor] response

@return [Boolean]

@api private

Calls superclass method Dry::Types::Decorator#decorate?
# File lib/dry/types/lax.rb, line 66
def decorate?(response)
  super || response.is_a?(type.constructor_type)
end