Class: ActiveRecord::PredicateBuilder::RangeHandler

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

Overview

:nodoc:

Defined Under Namespace

Classes: RangeWithBinds

Instance Method Summary collapse

Constructor Details

#initialize(predicate_builder) ⇒ RangeHandler

Returns a new instance of RangeHandler.


8
9
10
# File 'activerecord/lib/active_record/relation/predicate_builder/range_handler.rb', line 8

def initialize(predicate_builder)
  @predicate_builder = predicate_builder
end

Instance Method Details

#call(attribute, value) ⇒ Object


12
13
14
15
16
# File 'activerecord/lib/active_record/relation/predicate_builder/range_handler.rb', line 12

def call(attribute, value)
  begin_bind = predicate_builder.build_bind_attribute(attribute.name, value.begin)
  end_bind = predicate_builder.build_bind_attribute(attribute.name, value.end)
  attribute.between(RangeWithBinds.new(begin_bind, end_bind, value.exclude_end?))
end