方法
类公共方法
new(permitted_classes: [], unsafe_load: nil) 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/coders/yaml_column.rb, line 9 def initialize(permitted_classes: [], unsafe_load: nil) @permitted_classes = permitted_classes @unsafe_load = unsafe_load end
实例公共方法
dump(object) 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/coders/yaml_column.rb, line 15 def dump(object) if @unsafe_load.nil? ? ActiveRecord.use_yaml_unsafe_load : @unsafe_load ::YAML.dump(object) else ::YAML.safe_dump( object, permitted_classes: @permitted_classes + ActiveRecord.yaml_column_permitted_classes, aliases: true, ) end end
load(payload) 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/coders/yaml_column.rb, line 33 def load(payload) if @unsafe_load.nil? ? ActiveRecord.use_yaml_unsafe_load : @unsafe_load YAML.unsafe_load(payload) else YAML.safe_load( payload, permitted_classes: @permitted_classes + ActiveRecord.yaml_column_permitted_classes, aliases: true, ) end end