Lots of files got moved around,a nd some got added.
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / MethodProvider / Util.pm
@@ -1,7 +1,10 @@
-package MooseX::AttributeHelpers::Collection::TypeCheck;
+package MooseX::AttributeHelpers::MethodProvider::Util;
+use strict;
+use warnings;
+
 use Exporter qw(import);
 use Carp qw(confess);
-our @EXPORT = qw(type_check);
+our @EXPORT_OK = qw(type_check);
 
 our $VERSION   = '0.01';
 our $AUTHORITY = 'cpan:STEVAN';
@@ -28,25 +31,31 @@ sub type_check {
 
 =head1 NAME
 
-MooseX::AttributeHelpers::Collection::TypeCheck
+MooseX::AttributeHelpers::MethodProvider::Util
 
 =head1 SYNOPSIS
 
-    use MooseX::AttributeHelpers::Collection::TypeCheck;
+    use MooseX::AttributeHelpers::MethodProvider;
+    use MooseX::AttributeHelpers::MethodProvider::Util qw(type_check);
+
+    add_method_provider 'Collection::Array' => (
+        type     => 'ArrayRef',
+        provides => {
+            push => sub {
+                my ($attr, $reader, $writer) = @_;
+                return type_check($attr, sub {@_[1,$#_]}, sub {
+                    my $self = shift;
+                    push(@{ $reader->($self) }, @_);
+                });
+            },
+        }
+    );
 
-    sub push : method {
-        my ($attr, $reader, $writer) = @_;
-        return type_check($attr, sub {@_[1,$#_]}, sub {
-            my $self = shift;
-            CORE::push(@{ $reader->($self) }, @_);
-        });
-    }
-  
 =head1 DESCRIPTION
 
-This module provides one function (type_check) which is exported by default.
-It is useful when writing method providers for that involve checks on
-parameterized types.
+This module provides one function (type_check) which is not exported unless
+requested.  It is useful when writing method providers for that involve checks 
+on parameterized types.
 
 =head1 SUBROUTINES