Class::Param::Decorator - Class Param Decorator Class


Class-Param documentation Contained in the Class-Param distribution.

Index


Code Index:

NAME

Top

Class::Param::Decorator - Class Param Decorator Class

SYNOPSIS

Top

    package MyDecorator;
    use base 'Class::Param::Decorator';

    sub get {
        # do something
    }

DESCRIPTION

Top

METHODS

Top

new

Constructor. Takes one argument, an instance of Class::Param::Base.

initialize

Called after construction with same arguments given to constructor, should return the instance.

decorated

Returns the decorated Class::Param::Base instance.

get

This method simply performs $self-decorated->get> and returns the result.

set

This method simply performs $self-decorated->set> and returns the result.

has

This method simply performs $self-decorated->has> and returns the result.

count

This method simply performs $self-decorated->count> and returns the result.

clear

This method simply performs $self-decorated->clear> and returns the result.

names

This method simply performs $self-decorated->names> and returns the result.

remove

This method simply performs $self-decorated->remove> and returns the result.

SEE ASLO

Top

Class::Param.

Class::Param::Base.

AUTHOR

Top

Christian Hansen chansen@cpan.org

COPYRIGHT

Top


Class-Param documentation Contained in the Class-Param distribution.

package Class::Param::Decorator;

use strict;
use warnings;
use base 'Class::Param::Base';

our $AUTOLOAD;

use Params::Validate qw[];

sub new {
    my $class = ref $_[0] ? ref shift : shift;
    my $self  = Params::Validate::validate_with(
        params  => \@_,
        spec    => [
            {
                type      => Params::Validate::OBJECT,
                isa       => 'Class::Param::Base',
                optional  => 0
            }
        ],
        called  => "$class\::new"
    );

    return bless( $self, $class )->initialize(@_);
}

sub initialize {
    return $_[0];
}

sub decorated {
    return $_[0]->[0];
}

sub get    { return shift->decorated->get    (@_) }
sub set    { return shift->decorated->set    (@_) }
sub has    { return shift->decorated->has    (@_) }
sub count  { return shift->decorated->count  (@_) }
sub clear  { return shift->decorated->clear  (@_) }
sub names  { return shift->decorated->names  (@_) }
sub remove { return shift->decorated->remove (@_) }

sub AUTOLOAD {
    my $self   = shift;
    my $method = substr( $AUTOLOAD, rindex( $AUTOLOAD, ':' ) + 1 );
    return $self->decorated->$method(@_);
}

sub DESTROY { }

1;

__END__