I have many scopes that use date ranges to do something, e.g. clicks_between(start_date, end_date). I also have want to support adding in a school year string, where we have an existing SchoolYear that has a start and end methods.
I could do something like:
scope :clicks_during, -> (year) {
year = Year.new(year) if year.is_a?(Integer)
send('clicks_between', year.start, year.end)
}
However, I'd rather not have to copy and paste this code everywhere. Is there a way to just dynamically add this scope if the "betweeen" scope exists already?