Class: Just
Instance Method Summary collapse
- #+@ ⇒ Object
-
#initialize(obj) ⇒ Just
constructor
A new instance of Just.
- #inspect ⇒ Object
- #method_missing(*args, &block) ⇒ Object
Methods included from Maybe
Constructor Details
#initialize(obj) ⇒ Just
Returns a new instance of Just.
22 23 24 25 26 27 28 |
# File 'lib/mayhaps.rb', line 22 def initialize(obj) if ::Maybe === obj || !obj.nil? @value = obj else ::Kernel.raise ::ArgumentError, 'object is nil' end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
34 35 36 |
# File 'lib/mayhaps.rb', line 34 def method_missing(*args, &block) @value.public_send(*args, &block).maybe end |