Browse files

keep the recursion stack clean even if there's an exception (credit: …

…Ian Smith-Heisters)
  • Loading branch information...
1 parent 5828485 commit 8ca1d4a81f0c9481c953a2d77179aeb215eb4870 @cainlevy committed Jan 7, 2009
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/recursion_control.rb
View
3 lib/recursion_control.rb
@@ -21,7 +21,8 @@ def without_recursion(method, default = true, &block)
return default if RecursionControl.stack[method].include? self
RecursionControl.stack[method] << self
result = yield
+ ensure
RecursionControl.stack[method].delete(self)
- return result
+ result
end
end

0 comments on commit 8ca1d4a

Please sign in to comment.