Sha256: 6af50543339743cf1641d6ab87a61ecac05db955ac1eeca76b226d86d362f5a3
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require "yaml" module PaperTrail module Serializers # The default serializer for, e.g. `versions.object`. module YAML extend self # makes all instance methods become module methods as well def load(string) ::YAML.respond_to?(:unsafe_load) ? ::YAML.unsafe_load(string) : ::YAML.load(string) end # @param object (Hash | HashWithIndifferentAccess) - Coming from # `recordable_object` `object` will be a plain `Hash`. However, due to # recent [memory optimizations](https://git.io/fjeYv), when coming from # `recordable_object_changes`, it will be a `HashWithIndifferentAccess`. def dump(object) object = object.to_hash if object.is_a?(HashWithIndifferentAccess) ::YAML.dump object end # Returns a SQL LIKE condition to be used to match the given field and # value in the serialized object. def where_object_condition(arel_field, field, value) arel_field.matches("%\n#{field}: #{value}\n%") end end end end
Version data entries
3 entries across 3 versions & 2 rubygems