summaryrefslogtreecommitdiff
path: root/ext/psych
diff options
context:
space:
mode:
Diffstat (limited to 'ext/psych')
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb24
1 files changed, 10 insertions, 14 deletions
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index cfed8f1814..ed8d9e2dfe 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -185,13 +185,11 @@ module Psych
@emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
- {
- 'message' => private_iv_get(o, 'mesg'),
- 'backtrace' => private_iv_get(o, 'backtrace'),
- }.each do |k,v|
- next unless v
- @emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY
- accept v
+ msg = private_iv_get(o, 'mesg')
+
+ if msg
+ @emitter.scalar 'message', nil, nil, true, false, Nodes::Scalar::ANY
+ accept msg
end
dump_ivars o
@@ -204,13 +202,11 @@ module Psych
@emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
- {
- 'message' => o.message.to_s,
- 'backtrace' => private_iv_get(o, 'backtrace'),
- }.each do |k,v|
- next unless v
- @emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY
- accept v
+ msg = o.message.to_s
+
+ if msg
+ @emitter.scalar 'message', nil, nil, true, false, Nodes::Scalar::ANY
+ accept msg
end
dump_ivars o