Bump to 0.14
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Collection / Array.pm
index 1bd9976..302e1ea 100644 (file)
@@ -1,78 +1,26 @@
 
 package MooseX::AttributeHelpers::Collection::Array;
 use Moose;
-use Moose::Util::TypeConstraints;
 
-our $VERSION   = '0.01';
+our $VERSION   = '0.14';
+$VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
-extends 'MooseX::AttributeHelpers::Base';
-
-has '+method_constructors' => (
-    default => sub {
-        return +{
-            'push' => sub {
-                my $attr = shift;
-                return sub { 
-                    my $instance = shift;
-                    push @{$attr->get_value($instance)} => @_; 
-                };
-            },
-            'pop' => sub {
-                my $attr = shift;
-                return sub { pop @{$attr->get_value($_[0])} };
-            },    
-            'unshift' => sub {
-                my $attr = shift;
-                return sub { 
-                    my $instance = shift;
-                    unshift @{$attr->get_value($instance)} => @_; 
-                };
-            },    
-            'shift' => sub {
-                my $attr = shift;
-                return sub { shift @{$attr->get_value($_[0])} };
-            },    
-            'get' => sub {
-                my $attr = shift;
-                return sub { $attr->get_value($_[0])->[$_[1]] };
-            },    
-            'set' => sub {
-                my $attr = shift;
-                return sub { $attr->get_value($_[0])->[$_[1]] = $_[2] };
-            },    
-            'count' => sub {
-                my $attr = shift;
-                return sub { scalar @{$attr->get_value($_[0])} };        
-            },
-            'empty' => sub {
-                my $attr = shift;
-                return sub { scalar @{$attr->get_value($_[0])} ? 1 : 0 };        
-            }
-        }
-    }
-);
-
-sub _process_options_for_provides {
-    my ($self, $options) = @_;
-    (exists $options->{isa})
-        || confess "You must define a type with the Array metaclass";  
+use MooseX::AttributeHelpers::MethodProvider::Array;
 
-    my $isa = $options->{isa}; 
+extends 'MooseX::AttributeHelpers::Collection';
 
-    unless (blessed($isa) && $isa->isa('Moose::Meta::TypeConstraint')) {
-        $isa = find_type_constraint($isa);        
-    }
+has '+method_provider' => (
+    default => 'MooseX::AttributeHelpers::MethodProvider::Array'
+);
 
-    ($isa->is_a_type_of('ArrayRef'))
-        || confess "The type constraint for a Array ($options->{isa}) must be a subtype of ArrayRef";
-}
+sub helper_type { 'ArrayRef' }
 
 no Moose;
-no Moose::Util::TypeConstraints;;
 
 # register the alias ...
-package Moose::Meta::Attribute::Custom::Collection::Array;
+package # hide me from search.cpan.org
+    Moose::Meta::Attribute::Custom::Collection::Array;
 sub register_implementation { 'MooseX::AttributeHelpers::Collection::Array' }
 
 
@@ -84,15 +32,18 @@ __END__
 
 =head1 NAME
 
+MooseX::AttributeHelpers::Collection::Array
+
 =head1 SYNOPSIS
 
   package Stuff;
   use Moose;
+  use MooseX::AttributeHelpers;
   
   has 'options' => (
-      metaclass => 'Collection',
+      metaclass => 'Collection::Array',
       is        => 'ro',
-      isa       => 'ArrayRef',
+      isa       => 'ArrayRef[Int]',
       default   => sub { [] },
       provides  => {
           'push' => 'add_options',
@@ -102,8 +53,24 @@ __END__
 
 =head1 DESCRIPTION
 
+This module provides an Array attribute which provides a number of 
+array operations. See L<MooseX::AttributeHelpers::MethodProvider::Array>
+for more details.
+
 =head1 METHODS
 
+=over 4
+
+=item B<meta>
+
+=item B<method_provider>
+
+=item B<has_method_provider>
+
+=item B<helper_type>
+
+=back
+
 =head1 BUGS
 
 All complex software has bugs lurking in it, and this module is no 
@@ -116,7 +83,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2008 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>