Yukki::Role::Savable - Provides a mechanism for YAML-izing objects
version 0.991_005
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
This is intended to provide Yukki with a nice, neat way to save and load some configuration objects in a standard way.
my @attr = $obj->savable_attributes;
Returns the list of attributes to save in the YAML.
my $yaml_text = $obj->dump_yaml;
This converts the object to YAML and returns the ext.
my $obj = $class->load_yaml($yaml_text);
This constructs a new class from the data loaded from the given YAML text.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
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.
To install Yukki, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Yukki
CPAN shell
perl -MCPAN -e shell install Yukki
For more information on module installation, please visit the detailed CPAN module installation guide.