Sha256: fc9e15f16d886f1b137099299754fb82e91af71b4ed7c0f9aacda324a7357ae3
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'yaml' module PaperTrail module Serializers module YAML extend self # makes all instance methods become module methods as well def load(string) ::YAML.load string end def dump(object) ::YAML.dump object end # Returns a SQL 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 # Returns a SQL condition to be used to match the given field and value # in the serialized object_changes def where_object_changes_condition(arel_field, field, value) # Need to check first (before) and secondary (after) fields if defined?(::YAML::ENGINE) && ::YAML::ENGINE.yamler == 'psych' arel_field.matches("%\n#{field}:\n- #{value}\n%"). or(arel_field.matches("%\n#{field}:\n-%\n- #{value}\n%")) else # Syck adds extra spaces into array dumps arel_field.matches("%\n#{field}: \n%- #{value}\n%"). or(arel_field.matches("%\n#{field}: \n-%\n- #{value}\n%")) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paper_trail-4.0.0.beta2 | lib/paper_trail/serializers/yaml.rb |