Sha256: e9f197c910b47af62293e280b9d5dab2f66dd79d3fb81b4ecb62911d4722df9e

Contents?: true

Size: 471 Bytes

Versions: 2

Compression:

Stored size: 471 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Monads
    # @private
    module Curry
      # @private
      def self.call(value)
        func = value.is_a?(Proc) ? value : value.method(:call)
        seq_args = func.parameters.count { |type, _| type == :req || type == :opt }
        seq_args += 1 if func.parameters.any? { |type, _| type == :keyreq }

        if seq_args > 1
          func.curry
        else
          func
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-monads-1.4.0 lib/dry/monads/curry.rb
dry-monads-1.3.5 lib/dry/monads/curry.rb