Sha256: 170219a514066ed1d4777579dc8ba7337fc59ebfc69bc764bdb56d2aa43720ca
Contents?: true
Size: 516 Bytes
Versions: 1
Compression:
Stored size: 516 Bytes
Contents
require 'dry/monads/maybe' require 'dry/types/decorator' module Dry module Types class Maybe include Decorator include Builder include Dry::Monads::Maybe::Mixin def call(input) input.is_a?(Dry::Monads::Maybe) ? input : Maybe(type[input]) end alias_method :[], :call def default(value) if value.nil? raise ArgumentError, "nil cannot be used as a default of a maybe type" else super end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-types-0.7.2 | lib/dry/types/maybe.rb |