From 461a56db2e64566d166ff62265fedad0752990d2 Mon Sep 17 00:00:00 2001 From: Joe Eli McIlvain Date: Thu, 15 Jan 2015 18:08:50 -0800 Subject: Only dump ivars for subclasses of String, not for String. With cf0dd2b93f1552a3c452a0bfa0e996f441d5e27e, fixes #217. --- lib/psych/visitors/yaml_tree.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/psych/visitors/yaml_tree.rb') diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index 35ebb27..c1039c6 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -325,10 +325,11 @@ module Psych style = Nodes::Scalar::SINGLE_QUOTED end - ivars = find_ivars o + is_primitive = o.class == ::String + ivars = find_ivars o, is_primitive if ivars.empty? - unless o.class == ::String + unless is_primitive tag = "!ruby/string:#{o.class}" plain = false quote = false @@ -533,7 +534,7 @@ module Psych end # FIXME: remove this method once "to_yaml_properties" is removed - def find_ivars target + def find_ivars target, is_primitive=false begin loc = target.method(:to_yaml_properties).source_location.first unless loc.start_with?(Psych::DEPRECATED) || loc.end_with?('rubytypes.rb') @@ -547,7 +548,7 @@ module Psych # and it's OK to skip it since it's only to emit a warning. end - target.instance_variables + is_primitive ? [] : target.instance_variables end def register target, yaml_obj -- cgit v1.2.3