Module: Fear::RightBiased::Interface

Included in:
Left
Defined in:
lib/fear/right_biased.rb

Overview

Performs necessary interface and type checks.

Instance Method Summary collapse

Instance Method Details

#detectObject

Ensures that returned value either left, or right.



20
21
22
23
24
# File 'lib/fear/right_biased.rb', line 20

def detect(*)
  super.tap do |result|
    Utils.assert_type!(result, left_class, right_class)
  end
end

#flat_mapObject



13
14
15
16
17
# File 'lib/fear/right_biased.rb', line 13

def flat_map
  super.tap do |result|
    Utils.assert_type!(result, left_class, right_class)
  end
end

#get_or_else(*args, &block) ⇒ Object

Returns the value from this RightBiased::Right or the given argument if this is a RightBiased::Left.



8
9
10
11
# File 'lib/fear/right_biased.rb', line 8

def get_or_else(*args, &block)
  Utils.assert_arg_or_block!('get_or_else', *args, &block)
  super
end