Class: ActiveRecord::PredicateBuilder::RangeHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/relation/predicate_builder/range_handler.rb

Overview

:nodoc:

Defined Under Namespace

Classes: RangeWithBinds

Instance Method Summary collapse

Instance Method Details

#call(attribute, value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/active_record/relation/predicate_builder/range_handler.rb', line 6

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