Sha256: af82f5271149a7ea0bedd2d5bf0e383d30d6fe8d0ef9f721f298681423ad2637
Contents?: true
Size: 590 Bytes
Versions: 1
Compression:
Stored size: 590 Bytes
Contents
# frozen_string_literal: true require_relative "safe_operation/version" require_relative "safe_operation/success" require_relative "safe_operation/failure" module SafeOperation NoFailureHandler = Class.new NotImplementedError def self.either(maybe_block) raise NoFailureHandler if !block_given? if maybe = maybe_block.call Success.new maybe else Failure.new yield end rescue StandardError Failure.new yield end NO_FAILURE_HANDLER_MESSAGE = "Please pass in a block to handle the failure 😅" private_constant :NO_FAILURE_HANDLER_MESSAGE end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
safe_operation-1.0.0 | lib/safe_operation.rb |