Class: Result::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/result/base.rb

Direct Known Subclasses

Failure, Success

Instance Method Summary collapse

Constructor Details

#initialize(to_wrap) ⇒ Base

Returns a new instance of Base.


4
5
6
# File 'lib/result/base.rb', line 4

def initialize(to_wrap)
  @wrapped = to_wrap
end

Instance Method Details

#and_thenObject


24
25
26
# File 'lib/result/base.rb', line 24

def and_then
  self
end

#errorObject


20
21
22
# File 'lib/result/base.rb', line 20

def error
  raise "not present"
end

#failure?Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/result/base.rb', line 12

def failure?
  false
end

#on_failureObject


36
37
38
# File 'lib/result/base.rb', line 36

def on_failure
  self
end

#on_successObject


32
33
34
# File 'lib/result/base.rb', line 32

def on_success
  self
end

#or_elseObject


28
29
30
# File 'lib/result/base.rb', line 28

def or_else
  self
end

#success?Boolean

Returns:

  • (Boolean)

8
9
10
# File 'lib/result/base.rb', line 8

def success?
  false
end

#valueObject


16
17
18
# File 'lib/result/base.rb', line 16

def value
  raise "not present"
end