Method: Pathname#load_yaml

Defined in:
lib/pleasant_path/yaml/pathname.rb

#load_yamlObject

Reads the file indicated by the Pathname, and parses the contents as YAML, deserializing arbitrary data types via type information embedded in the YAML. This is UNSAFE for YAML from an untrusted source. To consume untrusted YAML, use #read_yaml instead.

Examples:

Point = Struct.new(:x, :y)
point = Point.new(10, 20)
File.write("file.yaml", point.to_yaml)

Pathname.new("file.yaml").load_yaml  # == Point.new(10, 20)

Returns:



33
34
35
# File 'lib/pleasant_path/yaml/pathname.rb', line 33

def load_yaml
  YAML.load_file(self)
end