Skip to content

Commit

Permalink
Merge pull request #338 from stomar/doc_safe_load
Browse files Browse the repository at this point in the history
Improve docs for Psych.safe_load
  • Loading branch information
hsbt authored Dec 4, 2017
2 parents 843256b + 339cfc7 commit 6333cf8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/psych.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ def self.load yaml, filename = nil, fallback = false, symbolize_names: false
#
# A Psych::BadAlias exception will be raised if the yaml contains aliases
# but the +aliases+ parameter is set to false.
#
# +filename+ will be used in the exception message if any exception is raised
# while parsing.
#
# When the optional +symbolize_names+ keyword argument is set to a
# true value, returns symbols for keys in Hash objects (default: strings).
#
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
#
def self.safe_load yaml, whitelist_classes = [], whitelist_symbols = [], aliases = false, filename = nil, symbolize_names: false
result = parse(yaml, filename)
return unless result
Expand Down

0 comments on commit 6333cf8

Please sign in to comment.