Skip to content

Commit 8bf1f94

Browse files
authored
Merge pull request #755 from etiennebarrie/use-node-to-ruby-parse-symbols-option
Use Node#to_ruby parse_symbols option
2 parents be2eb69 + 907fd4f commit 8bf1f94

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/psych/nodes/node.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def each &block
4646
#
4747
# See also Psych::Visitors::ToRuby
4848
def to_ruby(symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true)
49-
Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer, parse_symbols: true).accept(self)
49+
Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer, parse_symbols: parse_symbols).accept(self)
5050
end
5151
alias :transform :to_ruby
5252

test/psych/visitors/test_to_ruby.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ def test_mapping_with_str_tag
328328
mapping.children << Nodes::Scalar.new('bar')
329329
assert_equal({'foo' => 'bar'}, mapping.to_ruby)
330330
end
331+
332+
def test_parse_symbols
333+
node = Nodes::Scalar.new(':foo')
334+
assert_equal :foo, node.to_ruby
335+
assert_equal ':foo', node.to_ruby(parse_symbols: false)
336+
end
331337
end
332338
end
333339
end

0 commit comments

Comments
 (0)