Module: IceNine::RecursionGuard
- Defined in:
- lib/ice_nine/support/recursion_guard.rb
Overview
Protect against infinite recursion
Class Method Summary collapse
-
.guard(object_id) ⇒ Object
Guard against recursively calling a block with the same object.
Class Method Details
.guard(object_id) ⇒ Object
Guard against recursively calling a block with the same object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ice_nine/support/recursion_guard.rb', line 20 def self.guard(object_id) objects = guarded_objects(caller.first) return if objects.include?(object_id) begin objects << object_id yield ensure objects.delete(object_id) end end |