File::Serialize::Serializer - Role for defining File::Serialize serializers
version 1.3.0
package File::Serialize::Serializer::MySerializer; use Module::Runtime qw/ use_module /; use Moo; with 'File::Serialize::Serializer'; sub extensions { 'mys' } sub init { use_module('SomeThing') } sub serialize { ...} sub deserialize { ...} 1;
This role is used to define serializers for File::Serialize.
As all the serializer plugins are typically loaded to figure out which one should be used to serialize/deserialize a specific file, it's important that the modules on which the serializer depends are not just used, but are rather marked for import via the required_modules and init functions.
use
required_modules
init
A serializer should implement the following class methods:
Required. Must return a list of all extensions that this serializer can deal with.
The first extension of the list will be considered the canonical extension.
Returns the list of modules that this serializer needs to operate.
If not provided, the required module will be extracted from the package name. I.e., the serializer File::Serialize::Serializer::YAML::Tiny will assume that it requires YAML::Tiny.
Required. Returns the serialized $data.
$data
Required. Returns the deserialized $data.
Takes in the generic serializer options and groom them for this specific one.
Groom the options for this specific serializer. If not provided, groom_options is used.
groom_options
The role provides the following attributes / methods:
Returns the serializer's precedence, used to determine which one of the available serializer for a format to use. Default to 100. A value of 0 means "don't use".
100
0
Yanick Champoux <yanick@cpan.org>
This software is copyright (c) 2019, 2017, 2016, 2015 by Yanick Champoux.
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 File::Serialize, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Serialize
CPAN shell
perl -MCPAN -e shell install File::Serialize
For more information on module installation, please visit the detailed CPAN module installation guide.