Sha256: ec36f80d945eb83bec0a0225493ddcde567aec84e294fcbd1d2daee66e5bbe4e
Contents?: true
Size: 749 Bytes
Versions: 2
Compression:
Stored size: 749 Bytes
Contents
# frozen_string_literal: true module Kind module Maybe module Wrappable def wrap(arg = UNDEFINED) if block_given? begin return new(yield) if UNDEFINED == arg input = __call_before_expose_the_arg_in_a_block(arg) input.kind_of?(Maybe::None) ? input : new(yield(input)) rescue StandardError => exception Maybe.__none__(exception) end else return new(arg) if UNDEFINED != arg raise ArgumentError, 'wrong number of arguments (given 0, expected 1)' end end private def __call_before_expose_the_arg_in_a_block(input) input end end private_constant :Wrappable end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kind-5.1.0 | lib/kind/core/maybe/wrappable.rb |
kind-5.0.0 | lib/kind/maybe/wrappable.rb |