query_attribute.rb 386 字节
Newer Older
K
Kir Shatrov 已提交
1
# frozen_string_literal: true
2
require "active_record/attribute"
S
Sean Griffin 已提交
3 4 5

module ActiveRecord
  class Relation
6
    class QueryAttribute < Attribute # :nodoc:
S
Sean Griffin 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20
      def type_cast(value)
        value
      end

      def value_for_database
        @value_for_database ||= super
      end

      def with_cast_value(value)
        QueryAttribute.new(name, value, type)
      end
    end
  end
end