NAME

Data::Object::Yaml

ABSTRACT

Data-Object Yaml Class

SYNOPSIS

  use Data::Object::Yaml;

  my $yaml = Data::Object::Yaml->new;

  my $data = $yaml->from($arg);

DESCRIPTION

Data::Object::Yaml provides methods for reading and writing YAML data.

METHODS

This package implements the following methods.

dump

  dump(HashRef $arg1) : Str

The dump method converts a data structure into a YAML string.

dump example
  # given $yaml

  my $string = $yaml->dump($data);

  # '--- {name: ...}'

file

  file() : Object

The file method returns a Data::Object::Path object for the given file.

file example
  # given $yaml

  my $path = $yaml->file($file);

  # ...

from

  from(Any $arg1) : Any

The from method calls dump or load based on the give data.

from example
  # given $yaml

  my $data = $yaml->from($string);

  # {,...}

  my $string = $yaml->from($data);

  # '--- {foo: ...}'

load

  load(Str $arg1) : HashRef

The load method converts a string into a Perl data structure.

load example
  # given $yaml

  my $data = $yaml->load($string);

  # {,...}

origin

  origin() : Str

The origin method returns the package name of the underlying YAML library used.

origin example
  # given $yaml

  my $origin = $yaml->origin();

  # YAML::Tiny

read

  read(Str $arg1) : HashRef

The read method reads YAML from the given file and returns a data structure.

read example
  # given $yaml

  my $data = $yaml->read($file);

  # {,...}

space

  space() : Object

The space method returns a Data::Object::Space object for the origin.

space example
  # given $yaml

  my $space = $yaml->space();

  # YAML::Tiny

write

  writes(Str $arg1, HashRef $arg2) : Str

The write method writes the given data structure to a file as a YAML string.

write example
  # given $yaml

  my $string = $yaml->write($file, $data);

  # ...