Sha256: 016614052a2907c44c9db175a7904d90f896c08dd4ffd6b6a57477b70a1eec61

Contents?: true

Size: 938 Bytes

Versions: 33

Compression:

Stored size: 938 Bytes

Contents

module ActiveRecord
  class PredicateBuilder
    class RangeHandler # :nodoc:
      RangeWithBinds = Struct.new(:begin, :end, :exclude_end?)

      def initialize(predicate_builder)
        @predicate_builder = predicate_builder
      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

      protected

      attr_reader :predicate_builder
    end
  end
end

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
activerecord-5.0.7.2 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.7.1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.7 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.6 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.6.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.5 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.5.rc2 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.5.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.4 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.4.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.3 lib/active_record/relation/predicate_builder/range_handler.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activerecord-5.0.2/lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.2 lib/active_record/relation/predicate_builder/range_handler.rb
activerecord-5.0.2.rc1 lib/active_record/relation/predicate_builder/range_handler.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/relation/predicate_builder/range_handler.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/relation/predicate_builder/range_handler.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/relation/predicate_builder/range_handler.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/relation/predicate_builder/range_handler.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/relation/predicate_builder/range_handler.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/relation/predicate_builder/range_handler.rb