diff options
author | SHIBATA Hiroshi <hsbt@ruby-lang.org> | 2017-12-04 10:54:11 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-04 10:54:11 +0900 |
commit | 6333cf8cc365b644fbffd8b122f2e720f5654e77 (patch) | |
tree | 581f84592edd47fb9fb3adbe27e883a5faaed28c /lib | |
parent | 843256b841b257d8140dc0872d5aa19dbc1d36a4 (diff) | |
parent | 339cfc72c6aa4f4f0c6d06f8d7e3fdd6acd9e0fc (diff) | |
download | psych-6333cf8cc365b644fbffd8b122f2e720f5654e77.tar.gz |
Merge pull request #338 from stomar/doc_safe_load
Improve docs for Psych.safe_load
Diffstat (limited to 'lib')
-rw-r--r-- | lib/psych.rb | 10 |
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 |