Module: Psych

Defined in:
lib/psych/simple.rb

Defined Under Namespace

Classes: SimpleHandler

Class Method Summary collapse

Class Method Details

.simple_load(yaml, options = nil) ⇒ Object

Load yaml in to a ruby data structure.

This function is 2-5x faster as compared to Psych::load but supports a simplified (and safe) data format only. All values are deserialized as strings. Anchors and tags are not supported, and thus ruby objects are not supported either.

Options can have the following keys,

  • filename: used in the exception message (defaults to nil)

  • symbolize_names: if true return symbols as keys in a yaml mapping, otherwise strings are returned (defaults to false)



17
18
19
20
21
# File 'lib/psych/simple.rb', line 17

def self.simple_load(yaml, options = nil)
  parser = Parser.new(SimpleHandler.new(options))
  parser.parse yaml, options && options[:filename]
  parser.handler.document
end