Moritz Onken > MooseX-Traits-Attribute-MergeHashRef > MooseX::Traits::Attribute::MergeHashRef

Download:
MooseX-Traits-Attribute-MergeHashRef-1.002.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 1.002   Source  

NAME ^

MooseX::Traits::Attribute::MergeHashRef

VERSION ^

version 1.002

SYNOPSIS ^

    package MyClass;
    use Moose;
    has stash => ( is => 'rw', isa => 'HashRef', traits => [qw(MergeHashRef)] );

    my $class = MyClass->new;
    $class->stash({ animals => { dogs => 1 } });
    # $class->stash: { animals => { dogs => 1 } }
    $class->stash({ animals => { cats => 2 } });
    # $class->stash: { animals => { dogs => 1, cats => 2 } }
    $class->set_stash({ foo => bar });
    # $class->stash: { foo => bar });
    $class->clear_stash;
    # $class->stash: undef

DESCRIPTION ^

This trait will merge values added to a HashRef attribute. It uses Hash::Merge to combine them. The method set_$attr which resets the attribute with a given hashref is also created. Call clear_$attr to clear the attribute.

NAME ^

MooseX::Traits::Attribute::MergeHashRef - Merging HashRef attribute

AUTHOR ^

Moritz Onken

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2011 by Moritz Onken.

This is free software, licensed under:

  The (three-clause) BSD License
syntax highlighting: