File: Mixins.pm

package info (click to toggle)
libvalidation-class-perl 7.900057-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,616 kB
  • sloc: perl: 21,493; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 878 bytes parent folder | download | duplicates (2)
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
39
40
41
# Container Class for Validation::Class::Mixin Objects

# Validation::Class::Mixins is a container class for L<Validation::Class::Mixin>
# objects and is derived from the L<Validation::Class::Mapping> class.

package Validation::Class::Mixins;

use strict;
use warnings;

use Validation::Class::Util '!has';

our $VERSION = '7.900057'; # VERSION

use base 'Validation::Class::Mapping';

use Validation::Class::Mixin;

sub add {

    my $self = shift;

    my $arguments = $self->build_args(@_);

    while (my ($key, $value) = each %{$arguments}) {

        # do not overwrite
        unless (defined $self->{$key}) {
            $self->{$key} = $value; # accept an object as a value
            $self->{$key} = Validation::Class::Mixin->new($value)
                unless "Validation::Class::Mixin" eq ref $self->{$key}
            ;
        }

    }

    return $self;

}

1;