Module: Dry::Monads::Curry

Defined in:
lib/dry/monads/curry.rb

Class Method Summary collapse

Class Method Details

.call(value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dry/monads/curry.rb', line 6

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