Skip to content

Commit

Permalink
Merge pull request #738 from koya1616/change-enable-sett
Browse files Browse the repository at this point in the history
change Bullet's feature enable logic
  • Loading branch information
flyerhzm authored Feb 26, 2025
2 parents 86654e7 + daf4e89 commit d59f350
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ Bullet.unused_eager_loading_enable = false
Bullet.counter_cache_enable = false
```

Note: When calling `Bullet.enable`, all other detectors are reset to their defaults (`true`) and need reconfiguring.

## Safe list

Sometimes Bullet may notify you of query problems you don't care to fix, or
Expand Down
8 changes: 4 additions & 4 deletions lib/bullet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def raise=(should_raise)
].freeze

def enable=(enable)
@enable = @n_plus_one_query_enable = @unused_eager_loading_enable = @counter_cache_enable = enable
@enable = enable

if enable?
reset_safelist
Expand All @@ -90,15 +90,15 @@ def app_root
end

def n_plus_one_query_enable?
enable? && !!@n_plus_one_query_enable
enable? && (@n_plus_one_query_enable.nil? ? true : @n_plus_one_query_enable)
end

def unused_eager_loading_enable?
enable? && !!@unused_eager_loading_enable
enable? && (@unused_eager_loading_enable.nil? ? true : @unused_eager_loading_enable)
end

def counter_cache_enable?
enable? && !!@counter_cache_enable
enable? && (@counter_cache_enable.nil? ? true : @counter_cache_enable)
end

def stacktrace_includes
Expand Down

0 comments on commit d59f350

Please sign in to comment.