Sha256: fdd991c72d7ca7cd997b81fea97756a7b04dac689146a19ede0c0d3d6d996acd

Contents?: true

Size: 480 Bytes

Versions: 11

Compression:

Stored size: 480 Bytes

Contents

# frozen_string_literal: true

module Pipeable
  module Steps
    # Sends a risky message to an object which may pass or fail.
    class Try < Abstract
      def initialize(*, catch:, **)
        super(*, **)
        @catch = catch
      end

      def call result
        result.fmap { |object| object.public_send(*base_positionals, **base_keywords) }
      rescue *Array(catch) => error
        Failure error
      end

      private

      attr_reader :catch
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pipeable-1.1.0 lib/pipeable/steps/try.rb
pipeable-1.0.0 lib/pipeable/steps/try.rb
pipeable-0.14.0 lib/pipeable/steps/try.rb
pipeable-0.13.0 lib/pipeable/steps/try.rb
pipeable-0.12.0 lib/pipeable/steps/try.rb
pipeable-0.11.0 lib/pipeable/steps/try.rb
pipeable-0.10.0 lib/pipeable/steps/try.rb
pipeable-0.9.1 lib/pipeable/steps/try.rb
pipeable-0.9.0 lib/pipeable/steps/try.rb
pipeable-0.8.0 lib/pipeable/steps/try.rb
pipeable-0.7.0 lib/pipeable/steps/try.rb