-
Notifications
You must be signed in to change notification settings - Fork 203
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
Dan criteria instances #282
Conversation
(Repeat of private email): The “Criteria” class could be the place for queries like the badge level, as well as ways to get particular sets of Criteria (e.g., the “active” / non-future criteria). |
It seems like the class/instance method distinction perfectly matches the difference between Criteria and each criterion. |
@david-a-wheeler Could I please get the OK to merge? |
Ok to merge! |
@david-a-wheeler Please review this work to convert Criteria to a real class with an instance for each criterion. The key insight was from http://stackoverflow.com/a/36559091/1935918 which is that the class can and should instantiate if it is ever empty, such as on first use and when using
reload!
from rails console.Regarding accessors, please note that you are currently testing for 3 accessors that are not present in
criteria.yml
. I dynamically generate the set of unique accessors and then manually add in those 3, plus:name
.Also note that I added memoization for most class methods via
.each
, which calls.all
, which is memoized. I separately added memoization for.active
and each use of.find_by_name
.Comments welcome as always. Otherwise, please mark that you approve and I'll squash merge.