-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have the subset_conditions plugin support where_all and where_any met…
…hods to combine existing subsets with AND or OR This DRYs up code such as: plugin :subset_conditions dataset_module do where :a, :a where :b, :b where :a_and_b do where(a_conditions).where(b_conditions) end where :a_or_b do where(a_conditions).or(b_conditions) end end Now you can do: plugin :subset_conditions dataset_module do where :a, :a where :b, :b where_all :a_and_b, :a, :b where_any :a_or_b, :a, :b end In addition to being DRYer, this also makes the a_and_b and a_or_b methods faster, as they will support caching in the same way that the a and b methods do. Additionally, make the subset_conditions plugin create *_conditions methods for subsets created by the exclude method. This makes it so you don't have to manually invert the conditions and use the where or subset method in order to get the *_conditions method created, and allows filters created with exclude to be used as input to the where_all and where_any methods.
- Loading branch information
1 parent
e566408
commit fe99976
Showing
3 changed files
with
117 additions
and
5 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
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