blob: 98a5968183132a3f0cc92d232d9ecd6fd4ef6dfc (
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
30
31
32
33
34
35
|
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
module OID # :nodoc:
class Json < Type::Value # :nodoc:
include Type::Helpers::Mutable
def type
:json
end
def deserialize(value)
if value.is_a?(::String)
::ActiveSupport::JSON.decode(value) rescue nil
else
super
end
end
def serialize(value)
if value.is_a?(::Array) || value.is_a?(::Hash)
::ActiveSupport::JSON.encode(value)
else
super
end
end
def accessor
ActiveRecord::Store::StringKeyedHashAccessor
end
end
end
end
end
end
|