Module: PaperTrail::Serializers::YAML

Extended by:
YAML
Included in:
YAML
Defined in:
lib/paper_trail/serializers/yaml.rb

Overview

The default serializer for, e.g. versions.object.

Instance Method Summary collapse

Instance Method Details

#dump(object) ⇒ Object



15
16
17
# File 'lib/paper_trail/serializers/yaml.rb', line 15

def dump(object)
  ::YAML.dump object
end

#load(string) ⇒ Object



11
12
13
# File 'lib/paper_trail/serializers/yaml.rb', line 11

def load(string)
  ::YAML.load string
end

#where_object_changes_conditionObject

Returns a SQL LIKE condition to be used to match the given field and value in the serialized object_changes.



27
28
29
30
31
32
33
34
35
# File 'lib/paper_trail/serializers/yaml.rb', line 27

def where_object_changes_condition(*)
  raise "    where_object_changes no longer supports reading YAML from a text\n    column. The old implementation was inaccurate, returning more records\n    than you wanted. This feature was deprecated in 8.1.0 and removed in\n    9.0.0. The json and jsonb datatypes are still supported. See\n    discussion at https://github.com/paper-trail-gem/paper_trail/pull/997\n  STR\nend\n".squish.freeze

#where_object_condition(arel_field, field, value) ⇒ Object

Returns a SQL LIKE condition to be used to match the given field and value in the serialized object.



21
22
23
# File 'lib/paper_trail/serializers/yaml.rb', line 21

def where_object_condition(arel_field, field, value)
  arel_field.matches("%\n#{field}: #{value}\n%")
end