forked from pboling/flag_shih_tzu
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented chained_flags_with, which allows optimizing the bit search
When you chain multiple named scope generated by FlagShihTzu, generated ActiveRecord query would look like this. Spaceship.warpdrive.shields.not_electrolytes # => (spaceships.flags in (1,3,5,7)) AND (spaceships.flags in (2,3,6,7)) AND (spaceships.flags not in (4,5,6,7)) With the chained_flags_with introduced with this patch, you can write the same query in an optimized search. Spaceship.chained_flags_with("flags", :warpdrive, :shields, :not_electrolytes) # => (spaceships.flags in (3)) You can also name it with the named scope: scope :listed, chained_flags_with("flags", :warpdrive, :shields, :not_electrolytes)
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b56b9ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a pull request for this! Looks awesome!