summaryrefslogtreecommitdiff
path: root/lib/psych.rb
diff options
context:
space:
mode:
authorMarcus Stollsteimer <sto.mar@web.de>2017-12-01 16:19:09 +0100
committerMarcus Stollsteimer <sto.mar@web.de>2017-12-01 16:19:09 +0100
commit339cfc72c6aa4f4f0c6d06f8d7e3fdd6acd9e0fc (patch)
tree2d87b708c97a5767bd493c95eb19ad56779f538e /lib/psych.rb
parentb620653700272dd71c22786f5042cd83bcfcfbc2 (diff)
downloadpsych-339cfc72c6aa4f4f0c6d06f8d7e3fdd6acd9e0fc.zip
Improve docs for Psych.safe_load
Mention filename argument and symbolize_names keyword argument.
Diffstat (limited to 'lib/psych.rb')
-rw-r--r--lib/psych.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/psych.rb b/lib/psych.rb
index 0f14fe4..aea3565 100644
--- a/lib/psych.rb
+++ b/lib/psych.rb
@@ -300,6 +300,16 @@ module Psych
#
# 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