Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change Bullet's feature enable logic #738

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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