class Fear::PartialFunction::OrElse

Composite function produced by +PartialFunction#or_else+ method @api private

Attributes

f1[R]

@!attribute f1

@return [Fear::PartialFunction]

@!attribute f2

@return [Fear::PartialFunction]
f2[R]

@!attribute f1

@return [Fear::PartialFunction]

@!attribute f2

@return [Fear::PartialFunction]

Public Class Methods

new(f1, f2) click to toggle source

@param f1 [Fear::PartialFunction] @param f2 [Fear::PartialFunction]

# File lib/fear/partial_function/or_else.rb, line 12
def initialize(f1, f2)
  @f1 = f1
  @f2 = f2
end

Public Instance Methods

===(arg)
Alias for: call
[](arg)
Alias for: call
and_then(other = Utils::UNDEFINED, &block) click to toggle source

@see Fear::PartialFunction#and_then

# File lib/fear/partial_function/or_else.rb, line 40
def and_then(other = Utils::UNDEFINED, &block)
  Utils.with_block_or_argument("Fear::PartialFunction::OrElse#and_then", other, block) do |fun|
    OrElse.new(f1.and_then(&fun), f2.and_then(&fun))
  end
end
call(arg) click to toggle source

@param arg [any] @return [any]

# File lib/fear/partial_function/or_else.rb, line 26
def call(arg)
  f1.call_or_else(arg, &f2)
end
Also aliased as: ===, []
call_or_else(arg, &fallback) click to toggle source

@param arg [any] @param fallback [Proc] @return [any]

# File lib/fear/partial_function/or_else.rb, line 55
def call_or_else(arg, &fallback)
  f1.call_or_else(arg) do
    return f2.call_or_else(arg, &fallback)
  end
end
defined_at?(arg) click to toggle source

@param arg [any] @return [Boolean]

# File lib/fear/partial_function/or_else.rb, line 48
def defined_at?(arg)
  f1.defined_at?(arg) || f2.defined_at?(arg)
end
or_else(other) click to toggle source

@param other [Fear::PartialFunction] @return [Fear::PartialFunction]

# File lib/fear/partial_function/or_else.rb, line 35
def or_else(other)
  OrElse.new(f1, f2.or_else(other))
end