aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/predicate_builder/class_handler.rb
blob: 810937ead67ed73ff8be889b46d2742839f1639a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module ActiveRecord
  class PredicateBuilder
    class ClassHandler # :nodoc:
      def initialize(predicate_builder)
        @predicate_builder = predicate_builder
      end

      def call(attribute, value)
        print_deprecation_warning
        predicate_builder.build(attribute, value.name)
      end

      # TODO Change this to private once we've dropped Ruby 2.2 support.
      # Workaround for Ruby 2.2 "private attribute?" warning.
      protected

        attr_reader :predicate_builder

      private

        def print_deprecation_warning
          ActiveSupport::Deprecation.warn(<<-MSG.squish)
            Passing a class as a value in an Active Record query is deprecated and
            will be removed. Pass a string instead.
          MSG
        end
    end
  end
end