json.rb 620 字节
Newer Older
1 2 3 4
module ActiveRecord
  module ConnectionAdapters
    module PostgreSQL
      module OID # :nodoc:
5
        class Json < Type::Value # :nodoc:
6 7
          include Type::Mutable

8 9 10 11
          def type
            :json
          end

12 13
          def type_cast_from_database(value)
            ConnectionAdapters::PostgreSQLColumn.string_to_json(value)
14 15
          end

16 17
          def type_cast_for_database(value)
            ConnectionAdapters::PostgreSQLColumn.json_to_string(value)
18 19 20 21 22 23 24 25 26 27
          end

          def accessor
            ActiveRecord::Store::StringKeyedHashAccessor
          end
        end
      end
    end
  end
end