Top Level Namespace
Defined Under Namespace
Classes: ContextNotFound
Instance Method Summary collapse
Instance Method Details
#finish(&block) ⇒ Object
3 4 5 |
# File 'lib/context_manager.rb', line 3 def finish(&block) Proc.new { |obj| block.call(obj) } end |
#with(*args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/context_manager.rb', line 7 def with(*args) begin arg = args[0] yield_obj = arg[0] rescue raise ContextNotFound, 'no context found' end raise ContextNotFound, 'no context found' if yield_obj.nil? begin yield yield_obj ensure arg[1].call(yield_obj) end end |