Class: Util::Maybe
- Inherits:
- BasicObject
- Defined in:
- lib/util.rb
Instance Method Summary collapse
-
#initialize(object, default = nil) ⇒ Maybe
constructor
A new instance of Maybe.
- #method_missing(method, *args, &block) ⇒ Object
- #send(method, *args, &block) ⇒ Object
Constructor Details
#initialize(object, default = nil) ⇒ Maybe
Returns a new instance of Maybe.
61 62 63 64 65 |
# File 'lib/util.rb', line 61 def initialize(object, default = nil) @object = object @default = default @block = block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
76 77 78 |
# File 'lib/util.rb', line 76 def method_missing(method, *args, &block) send(method, *args, &block) end |
Instance Method Details
#send(method, *args, &block) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/util.rb', line 68 def send(method, *args, &block) if @object.respond_to?(method) @object.send(method, *args, &block) else @default end end |