module Dry::Types::Type
Common Type
module denoting an object is a Type
@api public
Public Instance Methods
call(input = Undefined, &block)
click to toggle source
Apply type to a value
@overload call(input = Undefined)
Possibly unsafe coercion attempt. If a value doesn't match the type, an exception will be raised. @param [Object] input @return [Object]
@overload call(input = Undefined)
When a block is passed, {#call} will never throw an exception on failed coercion, instead it will call the block. @param [Object] input @yieldparam [Object] output Partially coerced value @return [Object]
@api public
# File lib/dry/types/type.rb, line 43 def call(input = Undefined, &block) if block_given? call_safe(input, &block) else call_unsafe(input) end end
Also aliased as: []
valid?(input = Undefined)
click to toggle source
Whether a value is a valid member of the type
@return [Boolean]
@api private
# File lib/dry/types/type.rb, line 18 def valid?(input = Undefined) call_safe(input) { return false } true end
Also aliased as: ===