This seems like such an obvious idea that I'm having trouble believing
I'm the first to think of it. Why not take ranges containing
Float::INFINITY and translate them to the appropriate greater than or
less than comparisons? Example:
class Person
scope :voters, -> { where(born_on: (-Float::INFINITY..18.years.ago)) }
end
This would generate something along the lines of "WHERE people.born_on
<= '1995-02-19'".
case
when other.begin == -Float::INFINITY && other.end == Float::INFINITY then Nodes::NotIn.new self,
when other.end == Float::INFINITY then Nodes::GreaterThanOrEqual.new(self, other.begin)
when other.begin == -Float::INFINITY && other.exclude_end? then Nodes::LessThan.new(self, other.end)
when other.begin == -Float::INFINITY then Nodes::LessThanOrEqual.new(self, other.end)
when other.exclude_end?
...