Class: Kind::Result::Failure

Inherits:
Monad
  • Object
show all
Defined in:
lib/kind/result/failure.rb

Constant Summary collapse

DEFAULT_TYPE =
:error

Instance Attribute Summary

Attributes inherited from Monad

#type, #value

Instance Method Summary collapse

Methods inherited from Monad

#===, [], #initialize, #on, #on_failure, #on_success

Methods included from Abstract

#failed?, #on, #on_failure, #on_success, #result?, #succeeded?, #success?, #to_ary

Constructor Details

This class inherits a constructor from Kind::Result::Monad

Instance Method Details

#failure?Boolean

Returns:



7
8
9
# File 'lib/kind/result/failure.rb', line 7

def failure?
  true
end

#inspectObject



29
30
31
# File 'lib/kind/result/failure.rb', line 29

def inspect
  '#<%s type=%p value=%p>' % ['Kind::Failure', type, value]
end

#map(_ = UNDEFINED, &_fn) ⇒ Object Also known as: |, >>, map!, then, then!, and_then, and_then!



17
18
19
# File 'lib/kind/result/failure.rb', line 17

def map(_ = UNDEFINED, &_fn)
  self
end

#value_or(default = UNDEFINED, &block) ⇒ Object



11
12
13
14
15
# File 'lib/kind/result/failure.rb', line 11

def value_or(default = UNDEFINED, &block)
  Error.invalid_default_arg! if UNDEFINED == default && !block

  UNDEFINED != default ? default : block.call(value)
end