pboling/flag_shih_tzu — pull request #23 by pboling (2012-11-13 14:17:06+00:00)
Title: 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)