Sha256: 31a2703f88347e96592cc1b4be775683dfc7161bb288471293931422a941974b

Contents?: true

Size: 785 Bytes

Versions: 20

Compression:

Stored size: 785 Bytes

Contents

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
activerecord-5.1.7 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.7.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.6.2 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.6.1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.6 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.5 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.5.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.4 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.4.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.3 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.3.rc3 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.3.rc2 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.3.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.2 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.2.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.0 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.0.rc2 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.0.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.1.0.beta1 lib/active_record/relation/predicate_builder/range_handler.rb