Class: ActiveRecord::PredicateBuilder::RangeHandler
- Inherits:
-
Object
- Object
- ActiveRecord::PredicateBuilder::RangeHandler
- Defined in:
- lib/active_record/relation/predicate_builder/range_handler.rb
Overview
:nodoc:
Defined Under Namespace
Classes: RangeWithBinds
Instance Method Summary collapse
- #call(attribute, value) ⇒ Object
-
#initialize(predicate_builder) ⇒ RangeHandler
constructor
A new instance of RangeHandler.
Constructor Details
#initialize(predicate_builder) ⇒ RangeHandler
Returns a new instance of RangeHandler.
6 7 8 |
# File 'lib/active_record/relation/predicate_builder/range_handler.rb', line 6 def initialize(predicate_builder) @predicate_builder = predicate_builder end |
Instance Method Details
#call(attribute, value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_record/relation/predicate_builder/range_handler.rb', line 10 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 |