module PaperTrail::Serializers::YAML
The default serializer for, e.g. `versions.object`.
Public Instance Methods
dump(object)
click to toggle source
@param object (Hash | HashWithIndifferentAccess) - Coming from `recordable_object` `object` will be a plain `Hash`. However, due to recent [memory optimizations](git.io/fjeYv), when coming from `recordable_object_changes`, it will be a `HashWithIndifferentAccess`.
# File lib/mongo_trails/serializers/yaml.rb, line 19 def dump(object) object = object.to_hash if object.is_a?(HashWithIndifferentAccess) ::YAML.dump object end
load(string)
click to toggle source
# File lib/mongo_trails/serializers/yaml.rb, line 11 def load(string) ::YAML.load string end
where_object_changes_condition(*)
click to toggle source
Returns a SQL LIKE condition to be used to match the given field and value in the serialized `object_changes`.
# File lib/mongo_trails/serializers/yaml.rb, line 32 def where_object_changes_condition(*) raise <<-STR.squish.freeze where_object_changes no longer supports reading YAML from a text column. The old implementation was inaccurate, returning more records than you wanted. This feature was deprecated in 8.1.0 and removed in 9.0.0. The json and jsonb datatypes are still supported. See discussion at https://github.com/paper-trail-gem/paper_trail/pull/997 STR end
where_object_condition(arel_field, field, value)
click to toggle source
Returns a SQL LIKE condition to be used to match the given field and value in the serialized object.
# File lib/mongo_trails/serializers/yaml.rb, line 26 def where_object_condition(arel_field, field, value) arel_field.matches("%\n#{field}: #{value}\n%") end