Class: Mayak::Monads::Maybe::None

Inherits:
Object
  • Object
show all
Extended by:
T::Generic, T::Helpers, T::Sig
Includes:
Mayak::Monads::Maybe
Defined in:
lib/mayak/monads/maybe.rb

Constant Summary collapse

Value =
type_member

Instance Method Summary collapse

Methods included from Mayak::Monads::Maybe

#==, #as, check, guard, sequence

Instance Method Details

#either(none_branch, some_branch) ⇒ Object



383
384
385
# File 'lib/mayak/monads/maybe.rb', line 383

def either(none_branch, some_branch)
  none_branch.call
end

#filter(&blk) ⇒ Object



342
343
344
# File 'lib/mayak/monads/maybe.rb', line 342

def filter(&blk)
  self
end

#flat_map(&blk) ⇒ Object



330
331
332
333
334
335
# File 'lib/mayak/monads/maybe.rb', line 330

def flat_map(&blk)
  T.cast(
    self,
    Maybe[T.type_parameter(:NewValue)]
  )
end

#map(&blk) ⇒ Object



317
318
319
320
321
322
# File 'lib/mayak/monads/maybe.rb', line 317

def map(&blk)
  T.cast(
    self,
    Maybe[T.type_parameter(:NewValue)]
  )
end

#none?Boolean

Returns:

  • (Boolean)


352
353
354
# File 'lib/mayak/monads/maybe.rb', line 352

def none?
  true
end

#recover(value) ⇒ Object



408
409
410
# File 'lib/mayak/monads/maybe.rb', line 408

def recover(value)
  Mayak::Monads::Maybe::Some.new(value)
end

#recover_with_maybe(maybe) ⇒ Object



418
419
420
# File 'lib/mayak/monads/maybe.rb', line 418

def recover_with_maybe(maybe)
  maybe
end

#some?Boolean

Returns:

  • (Boolean)


347
348
349
# File 'lib/mayak/monads/maybe.rb', line 347

def some?
  false
end

#tee(&blk) ⇒ Object



371
372
373
# File 'lib/mayak/monads/maybe.rb', line 371

def tee(&blk)
  self
end

#to_result(failure) ⇒ Object



393
394
395
# File 'lib/mayak/monads/maybe.rb', line 393

def to_result(failure)
  Mayak::Monads::Result::Failure[T.type_parameter(:Failure), Value].new(failure)
end

#to_try(error) ⇒ Object



398
399
400
# File 'lib/mayak/monads/maybe.rb', line 398

def to_try(error)
  Mayak::Monads::Try::Failure.new(error)
end

#value_or(value) ⇒ Object



362
363
364
# File 'lib/mayak/monads/maybe.rb', line 362

def value_or(value)
  value
end