NAME
Yukki::Role::Savable - Provides a mechanism for YAML-izing objects
VERSION
version 0.991_004
SYNOPSIS
package Yukki::Things;
use v5.24;
use Moo;
with 'Yukki::Role::Savable';
has foo => ( is => 'ro' );
has bar => ( is => 'ro' );
sub savable_attributes { qw( foo bar ) }
my $things = Yukki::Things->new(foo => 1, bar => 2);
path('file.yaml')->spew_utf8($things->dump_yaml);
my $things = Yukki::Things->load_yaml(path('file.yaml')->slurp_utf8);
say $things->foo; #> 1
say $things->bar; #> 2
DESCRIPTION
This is intended to provide Yukki with a nice, neat way to save and load some configuration objects in a standard way.
REQUIRED METHODS
savable_attributes
my @attr = $obj->savable_attributes;
Returns the list of attributes to save in the YAML.
METHODS
dump_yaml
my $yaml_text = $obj->dump_yaml;
This converts the object to YAML and returns the ext.
load_yaml
my $obj = $class->load_yaml($yaml_text);
This constructs a new class from the data loaded from the given YAML text.
AUTHOR
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.