Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Psych.safe_load_stream

safe_load_stream(yaml, filename: nil, permitted_classes: [], aliases: false) { |doc| ... }

Load multiple documents given in yaml. Returns the parsed documents as a list.

Example:

Example
Psych.safe_load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar']

list = []
Psych.safe_load_stream("--- foo\n...\n--- bar\n...") do |ruby|
  list << ruby
end
list # => ['foo', 'bar']