Sha256: b792ecedbbda762fe8dfeca962e23c629d5b5421cb1d3de71879a18d0994252c
Contents?: true
Size: 702 Bytes
Versions: 10
Compression:
Stored size: 702 Bytes
Contents
module Dry module Types class Constrained class Coercible < Constrained # @param [Object] input # @param [#call,nil] block # @yieldparam [Failure] failure # @yieldreturn [Result] # @return [Result,nil] def try(input, &block) result = type.try(input) if result.success? validation = rule.(result.input) if validation.success? result else failure = failure(result.input, validation) block ? yield(failure) : failure end else block ? yield(result) : result end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems