Class: Mooset::Optional
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #and_then(&block) ⇒ Object
-
#initialize(value) ⇒ Optional
constructor
A new instance of Optional.
Methods included from Monad
Constructor Details
#initialize(value) ⇒ Optional
Returns a new instance of Optional.
38 39 40 |
# File 'lib/mooset/monads.rb', line 38 def initialize(value) @value = value end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Mooset::Monad
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
37 38 39 |
# File 'lib/mooset/monads.rb', line 37 def value @value end |
Class Method Details
Instance Method Details
#and_then(&block) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/mooset/monads.rb', line 42 def and_then(&block) block = ensure_monadic_result(&block) if value.nil? self else block.call(value) end end |