方法
- A
- C
- D
- S
- T
包含的模块
常量
| JSON_ENCODER | = | ActiveSupport::JSON::Encoding.json_encoder.new(escape: false) |
实例公共方法
accessor() 链接
来源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/type/json.rb, line 38 def accessor ActiveRecord::Store::StringKeyedHashAccessor end
changed_in_place?(raw_old_value, new_value) 链接
来源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/type/json.rb, line 34 def changed_in_place?(raw_old_value, new_value) deserialize(raw_old_value) != new_value end
deserialize(value) 链接
来源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/type/json.rb, line 14 def deserialize(value) return value unless value.is_a?(::String) begin ActiveSupport::JSON.decode(value) rescue JSON::ParserError => e # NOTE: This may hide json with duplicate keys. We don't really want to just ignore it # but it's the best we can do in order to still allow updating columns that somehow already # contain invalid json from some other source. # See https://github.com/rails/rails/pull/55536 ActiveSupport.error_reporter.report(e, source: "application.active_record") nil end end
serialize(value) 链接
来源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/type/json.rb, line 30 def serialize(value) JSON_ENCODER.encode(value) unless value.nil? end
type() 链接
来源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/type/json.rb, line 10 def type :json end