HTML::FormFu::Inflator - Inflator Base Class


HTML-FormFu documentation Contained in the HTML-FormFu distribution.

Index


Code Index:

NAME

Top

HTML::FormFu::Inflator - Inflator Base Class

SYNOPSIS

Top

    my $inflator = $form->inflator( $type, @names );

DESCRIPTION

Top

Inflator Base Class.

METHODS

Top

names

Arguments: @names

Return Value: @names

Contains names of params to inflator.

process

Arguments: $form_result, \%params

CORE INFLATORS

Top

HTML::FormFu::Inflator::CompoundDateTime
HTML::FormFu::Inflator::DateTime

AUTHOR

Top

Carl Franks, cfranks@cpan.org

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


HTML-FormFu documentation Contained in the HTML-FormFu distribution.

package HTML::FormFu::Inflator;

use Moose;
extends 'HTML::FormFu::Processor';

use HTML::FormFu::Exception::Inflator;
use Scalar::Util qw( blessed );
use Carp qw( croak );

sub process {
    my ( $self, $values ) = @_;

    my $return;
    my @errors;

    if ( ref $values eq 'ARRAY' ) {
        my @return;
        for my $value (@$values) {
            ($return) = eval { $self->inflator($value) };

            if ($@) {
                push @errors, $self->return_error($@);
                push @return, undef;
            }
            else {
                push @return, $return;
            }
        }
        $return = \@return;
    }
    else {
        ($return) = eval { $self->inflator($values) };

        if ($@) {
            push @errors, $self->return_error($@);
        }
    }

    return ( $return, @errors );
}

sub return_error {
    my ( $self, $err ) = @_;

    if ( !blessed $err || !$err->isa('HTML::FormFu::Exception::Inflator') ) {
        $err = HTML::FormFu::Exception::Inflator->new;
    }

    return $err;
}

__PACKAGE__->meta->make_immutable;

1;

__END__