NAME

Raisin::Encoder - A helper for Raisin::Middleware::Formatter over encoder modules

VERSION

version 0.93

SYNOPSIS

    my $enc = Raisin::Encoder->new;
    $enc->register(xml => 'Some::XML::Formatter');
    $enc->for('json');
    $enc->media_types_map_flat_hash;

DESCRIPTION

Provides an easy interface to use and register encoders.

METHODS

register

Allows user to register their own encoders.

    $enc->register(xml => 'Some::XML::Formatter');

Also it can override "builtin" types as the user ones have more precedence.

    $enc->register(json => 'My::Own::JSON::Formatter');

builtin

Returns a list of encoders which are bundled with Raisin. They are: Raisin::Encoder::JSON, Raisin::Encoder::Text, Raisin::Encoder::YAML.

registered

Returns a list of encoders which were registered by user.

all

Returns a list of both "builtin" and "users".

for

Returns a class name for specified format.

media_types_map_flat_hash

Returns a hash of media types and associated formats.

AUTHOR

Artur Khabibullin

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by Artur Khabibullin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.