Sha256: 0f9adc321798006ee8246da7570ceff184cbf3d24ad9972073c04225862a810f

Contents?: true

Size: 440 Bytes

Versions: 13

Compression:

Stored size: 440 Bytes

Contents

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

13 entries across 13 versions & 1 rubygems

Version Path
dry-monads-1.3.4 lib/dry/monads/curry.rb
dry-monads-1.3.3 lib/dry/monads/curry.rb
dry-monads-1.3.2 lib/dry/monads/curry.rb
dry-monads-1.3.1 lib/dry/monads/curry.rb
dry-monads-1.3.0 lib/dry/monads/curry.rb
dry-monads-1.2.0 lib/dry/monads/curry.rb
dry-monads-1.1.0 lib/dry/monads/curry.rb
dry-monads-1.0.1 lib/dry/monads/curry.rb
dry-monads-1.0.0 lib/dry/monads/curry.rb
dry-monads-1.0.0.rc1 lib/dry/monads/curry.rb
dry-monads-1.0.0.beta3 lib/dry/monads/curry.rb
dry-monads-1.0.0.beta2 lib/dry/monads/curry.rb
dry-monads-1.0.0.beta1 lib/dry/monads/curry.rb