Method: Fear::PartialFunction::Guard.and

Defined in:
lib/fear/partial_function/guard.rb

.and(conditions) ⇒ Fear::PartialFunction::Guard

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • conditions (<#===>)

Returns:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fear/partial_function/guard.rb', line 32

def and(conditions)
  case conditions.size
  when 1 then and1(*conditions)
  when 2 then and2(*conditions)
  when 3 then and3(*conditions)
  when 0 then Any
  else
    head, *tail = conditions
    tail.reduce(new(head)) { |acc, condition| acc.and(new(condition)) }
  end
end