Module: Fear::RightBiased::Interface

Defined in:
lib/fear/right_biased.rb

Overview

Performs necessary interface and type checks.

Instance Method Summary collapse

Instance Method Details

#flat_mapObject


25
26
27
28
29
# File 'lib/fear/right_biased.rb', line 25

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`.


11
12
13
14
# File 'lib/fear/right_biased.rb', line 11

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

#or_else(*args, &block) ⇒ Object

Returns this `RightBiased::Right` or the given alternative if this is a `RightBiased::Left`.


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

def or_else(*args, &block)
  Utils.assert_arg_or_block!("or_else", *args, &block)
  super.tap do |result|
    Utils.assert_type!(result, left_class, right_class)
  end
end

#selectObject

Ensures that returned value either left, or right.


32
33
34
35
36
# File 'lib/fear/right_biased.rb', line 32

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