lib/protector.rb in protector-0.6.1 vs lib/protector.rb in protector-0.6.2

- old
+ new

@@ -23,13 +23,20 @@ "`Protector.paranoid = ...` is deprecated! Please change it to `Protector.config.paranoid = ...`" end # Allows executing any code having Protector globally disabled def insecurely(&block) + Thread.current[:protector_disabled_nesting] ||= 0 + Thread.current[:protector_disabled_nesting] += 1 + Thread.current[:protector_disabled] = true yield ensure - Thread.current[:protector_disabled] = false + Thread.current[:protector_disabled_nesting] -= 1 + + if Thread.current[:protector_disabled_nesting] == 0 + Thread.current[:protector_disabled] = false + end end def activate! ADAPTERS.each{|adapter| adapter.activate!} end \ No newline at end of file