X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FAttributeHelpers%2FCollection.pm;h=6b4514bf8958bd00135d22b1a263502acfa35443;hb=9a9764976656e1a089735d0cb1f1affd06f4d7e4;hp=d821b150f76cbf1593c59518f6e880fc046b34ea;hpb=69dde336792f25d5ed7d0a47d237a5382b4593a9;p=gitmo%2FMooseX-AttributeHelpers.git diff --git a/lib/MooseX/AttributeHelpers/Collection.pm b/lib/MooseX/AttributeHelpers/Collection.pm index d821b15..6b4514b 100644 --- a/lib/MooseX/AttributeHelpers/Collection.pm +++ b/lib/MooseX/AttributeHelpers/Collection.pm @@ -1,60 +1,13 @@ package MooseX::AttributeHelpers::Collection; use Moose; -use Moose::Util::TypeConstraints; -our $VERSION = '0.01'; +our $VERSION = '0.03'; our $AUTHORITY = 'cpan:STEVAN'; extends 'MooseX::AttributeHelpers::Base'; -has 'container_type' => ( - is => 'ro', - isa => 'Str', - predicate => 'has_container_type', -); - -has 'container_type_constraint' => ( - is => 'rw', - isa => 'Moose::Meta::TypeConstraint', - lazy => 1, - default => sub { - my $self = shift; - ($self->has_container_type) - || confess "You cannot create a container_type_constraint if you dont have a container type"; - - my $container_type = $self->container_type; - my $constraint = find_type_constraint($container_type); - - # NOTE: - # I am not sure DWIM-ery is a good thing - # here, so i am going to err on the side - # of caution, and blow up if you have - # not made a type constraint for this yet. - # - SL - (defined $constraint) - || confess "You must predefine the '$container_type' constraint before you can use it as a container type"; - - return $constraint; - } -); - -before 'process_options_for_provides' => sub { - my ($self, $options) = @_; - - if (exists $options->{isa}) { - my $type = $options->{isa}; - if ($type =~ /^(.*)\[(.*)\]$/) { - my $core_type = $1; - my $container_type = $2; - $options->{isa} = $core_type; - $options->{container_type} = $container_type; - } - } -}; - no Moose; -no Moose::Util::TypeConstraints; 1; @@ -64,12 +17,28 @@ __END__ =head1 NAME -=head1 SYNOPSIS +MooseX::AttributeHelpers::Collection - Base class for all collection type helpers =head1 DESCRIPTION +Documentation to come. + =head1 METHODS +=over 4 + +=item B + +=item B + +=item B + +=item B + +=item B + +=back + =head1 BUGS All complex software has bugs lurking in it, and this module is no