diff options
author | Jahfer Husain <jahfer.husain@shopify.com> | 2016-05-13 10:14:51 -0400 |
---|---|---|
committer | Jahfer Husain <jahfer.husain@shopify.com> | 2016-05-16 14:07:32 -0400 |
commit | 25801cfe78a124e868d7be068febf628d5fc1247 (patch) | |
tree | 00dd1ef10b4e73baa303bec2ddbda07733bd3833 /activerecord/lib | |
parent | 0991c4c6fc0c04764f34c6b65a42adce190440c3 (diff) | |
download | rails-25801cfe78a124e868d7be068febf628d5fc1247.tar.gz rails-25801cfe78a124e868d7be068febf628d5fc1247.tar.bz2 rails-25801cfe78a124e868d7be068febf628d5fc1247.zip |
Keep state around for nested calls to #suppress
If a call to #suppress from the same class occurred inside another #suppress
block, the suppression state would be set to false before the outer block
completes.
This change keeps the previous state around in memory and unwinds it
as the blocks exit.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/suppressor.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/suppressor.rb b/activerecord/lib/active_record/suppressor.rb index 8ec4b48d31..d9acb1a1dc 100644 --- a/activerecord/lib/active_record/suppressor.rb +++ b/activerecord/lib/active_record/suppressor.rb @@ -30,10 +30,11 @@ module ActiveRecord module ClassMethods def suppress(&block) + previous_state = SuppressorRegistry.suppressed[name] SuppressorRegistry.suppressed[name] = true yield ensure - SuppressorRegistry.suppressed[name] = false + SuppressorRegistry.suppressed[name] = previous_state end end |