1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00

Update YAML engine check for new Ruby versions

On Ruby 2.2.1, '::YAML' returns the class Psych, which has no ::ENGINE
constant defined.
This commit is contained in:
Michael Raimondi 2015-04-09 12:32:30 -04:00 committed by Ben Atkins
parent a98d88cb30
commit 237f7f7f09

View file

@ -23,7 +23,8 @@ module PaperTrail
# 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'
if (defined?(::YAML::ENGINE) && ::YAML::ENGINE.yamler == 'psych') ||
(defined?(::YAML) && defined?(Psych) && ::YAML == 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