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.
44 45 46 47 48 49 50 |
# File 'lib/mug/maybe.rb', line 44 def maybe &b if b self && instance_eval(&b) else MaybeDelegator.new(self) end end |