Method: Object#maybe
- Defined in:
- lib/mug/maybe.rb
#maybe(&b) ⇒ Object
Do something if this object is truthy.
If a block is given, it is executed in the context of this object, iff this object is neither nil nor false.
If no block is given, returns a MaybeDelegator object.
35 36 37 38 39 40 41 |
# File 'lib/mug/maybe.rb', line 35 def maybe &b if b self && instance_eval(&b) else MaybeDelegator.new(self) end end |