MooseX::Attribute::Prototype::Collection - Container class for MooseX::Attribute::Prototype::Object


MooseX-Attribute-Prototype documentation Contained in the MooseX-Attribute-Prototype distribution.

Index


Code Index:

NAME

Top

MooseX::Attribute::Prototype::Collection - Container class for MooseX::Attribute::Prototype::Object

VERSION

Top

0.10 - Released 2009-07-18

SYNOPSIS

Top

    use MooseX::Attribute::Prototype::Collection
    $collection = MooseX::Attribute::Prototype::Collection->new();

  # Add a MooseX::Attribute::Prototype::Object
    $collection->add_prototype( $prototype );

  # Retrieve a prototype from the collections
    $collection->get( 'MyRole/attr' );

  # Check if a prototype exists
    $collection->exists( 'MyRole/attr' );




DESCRIPTION

Top

This class is used internally by MooseX::Attribute::Prototype it serves as a container for holding the prototype objects. There is (as of yet) little reason to use this class directly.

SEE ALSO

Top

MooseX::Attribute::Prototype,

MooseX::Attribute::Prototype::Meta,

MooseX::Attribute::Prototype::Object,

Moose

MooseX::Role::Parameterized

MooseX::Types

AUTHOR

Top

Christopher Brown, <ctbrown at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-moosex-attribute-prototype at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Attribute-Prototype. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc MooseX::Attribute::Prototype

You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Attribute-Prototype

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/MooseX-Attribute-Prototype

* CPAN Ratings

http://cpanratings.perl.org/d/MooseX-Attribute-Prototype

* Search CPAN

http://search.cpan.org/dist/MooseX-Attribute-Prototype

ACKNOWLEDGEMENTS

Top

Though they would probably cringe to hear it, this effort would not have been possible without:

Shawn Moore

David Rolsky

Thomas Doran

Stevan Little

COPYRIGHT & LICENSE

Top


MooseX-Attribute-Prototype documentation Contained in the MooseX-Attribute-Prototype distribution.

# Collection Class for prototypes;
#   Key is role/prototype
#       
package MooseX::Attribute::Prototype::Collection;

    use Moose;
    use MooseX::AttributeHelpers;

    our $VERSION = '0.10';
    our $AUTHORITY = 'cpan:CTBROWN';

    has 'prototypes' => (
        is            => 'rw' ,
        isa           => 'HashRef[MooseX::Attribute::Prototype::Object]' ,
        default       => sub { {} } ,
        documentation => 'Slot containing hash of attribute prototypes' ,
        metaclass     => 'Collection::Hash' ,
        provides      => {
            set     => 'set' ,
            get     => 'get' , 
            count   => 'count' ,    
            exists  => 'exists' ,
            keys    => 'keys' ,
        } ,
    );

         

  # This is a simplified interface for set where you pass a prototype instead
  # of a name => prototype.
    sub add_prototype {
        
        my ( $self, $prototype ) = @_;
        $self->set( $prototype->name, $prototype );

    } 


  # set the reference property of the attribute described by key
    sub set_referenced { 

        $_[0]->get( $_[1] )->referenced(1);

            
    }


    no Moose;

1; # End of MooseX::Attribute::Prototype