Class: ReSorcery::Maybe::Nothing

Inherits:
Object
  • Object
show all
Includes:
Fielded
Defined in:
lib/re_sorcery/maybe/nothing.rb

Instance Method Summary collapse

Methods included from Fielded

#fields, included

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/re_sorcery/maybe/nothing.rb', line 30

def ==(other)
  other.class == Nothing
end

#and_thenObject



10
11
12
# File 'lib/re_sorcery/maybe/nothing.rb', line 10

def and_then
  self
end

#as_jsonObject



34
35
36
37
38
# File 'lib/re_sorcery/maybe/nothing.rb', line 34

def as_json(*)
  {
    kind: :nothing,
  }
end

#assign(_name) ⇒ Object



26
27
28
# File 'lib/re_sorcery/maybe/nothing.rb', line 26

def assign(_name)
  self
end

#get_or_else(&block) ⇒ Object



22
23
24
# File 'lib/re_sorcery/maybe/nothing.rb', line 22

def get_or_else(&block)
  block.call
end

#mapObject



14
15
16
# File 'lib/re_sorcery/maybe/nothing.rb', line 14

def map
  self
end

#or_else(&block) ⇒ Object



18
19
20
# File 'lib/re_sorcery/maybe/nothing.rb', line 18

def or_else(&block)
  ArgCheck['block', block.call, Just, Nothing]
end