File: FormAndBlockMethods.pm

package info (click to toggle)
libhtml-formfu-perl 2.05000-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,328 kB
  • ctags: 831
  • sloc: perl: 12,785; makefile: 9; sql: 5
file content (38 lines) | stat: -rw-r--r-- 842 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package HTML::FormFu::Role::FormAndBlockMethods;

use strict;
our $VERSION = '2.05'; # VERSION

use Moose::Role;

use HTML::FormFu::Util qw( _merge_hashes );
use Carp qw( croak );
use List::Util 1.33 qw( none );

sub default_args {
    my ( $self, $defaults ) = @_;

    $self->{default_args} ||= {};

    if ($defaults) {

        my @valid_types = qw(
            elements        deflators
            filters         constraints
            inflators       validators
            transformers    output_processors
        );

        for my $type ( keys %$defaults ) {
            croak "not a valid type for default_args: '$type'"
                if none { $type eq $_ } @valid_types;
        }

        $self->{default_args}
            = _merge_hashes( $self->{default_args}, $defaults );
    }

    return $self->{default_args};
}

1;