blob: ddd804b5088187e2a7886d356d23dd4f8419c136 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# frozen_string_literal: true
module ActiveRecord
class PredicateBuilder
class RangeHandler # :nodoc:
RangeWithBinds = Struct.new(:begin, :end, :exclude_end?)
def call(attribute, value)
if value.begin.respond_to?(:infinite?) && value.begin.infinite?
if value.end.respond_to?(:infinite?) && value.end.infinite?
attribute.not_in([])
elsif value.exclude_end?
attribute.lt(value.end)
else
attribute.lteq(value.end)
end
elsif value.end.respond_to?(:infinite?) && value.end.infinite?
attribute.gteq(value.begin)
elsif value.exclude_end?
attribute.gteq(value.begin).and(attribute.lt(value.end))
else
attribute.between(value)
end
end
end
end
end
|