NAME
Kelp::Module::YAML - YAML encoder / decoder for Kelp
SYNOPSIS
# in config
modules => [qw(YAML)],
modules_init => {
YAML => {
# options for the constructor
},
},
# in your application
my $encoded = $self->yaml->encode({
type => 'structure',
name => [qw(testing yaml)],
});
# Kelp 2.10 encoder factory
my $new_yaml = $self->get_encoder(yaml => 'name');
DESCRIPTION
This is a very straightforward module that enriches the Kelp framework with YAML serialization. It uses YAML::PP behind the scenes.
This module is compatible with Kelp 2.10 encoders feature, so you can use it as a factory for YAML processors by calling get_encoder
on the Kelp app object. It registers itself under the name yaml.
METHODS INTRODUCED TO KELP
yaml
my $yaml_facade = $kelp->yaml;
Returns the instance of an yaml facade. You can use this instance to invoke the methods listed below.
METHODS
encode
my $encoded = $kelp->yaml->encode($data);
A shortcut to $kelp->yaml->engine->dump_string
decode
my $decoded = $kelp->yaml->decode($yaml);
A shortcut to $kelp->yaml->engine->load_string
engine
my $yaml_engine = $kelp->yaml->engine;
Returns the instance of YAML::PP
CONFIGURATION
The entire configuration is fed to "new" in YAML::PP.
SEE ALSO
Kelp, the framework
AUTHOR
Bartosz Jarzyna, <bbrtj.pro@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2024 by Bartosz Jarzyna
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.