From: Stevan Little Date: Fri, 5 Oct 2007 14:33:11 +0000 (+0000) Subject: some new Array methods and some pod-coverage cleanup X-Git-Tag: 0.18_01~58 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b91f57afe2beaf8f2c49b42ea732c05332a8d04c;p=gitmo%2FMooseX-AttributeHelpers.git some new Array methods and some pod-coverage cleanup --- diff --git a/ChangeLog b/ChangeLog index 1811f44..690f5cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,7 +13,10 @@ Revision history for Perl extension MooseX-AttributeHelpers flexibility when writing additional helpers - removed check for 'provides' and 'isa' attr options before _process_options. It should be - called always. + called always. + + * MooseX::AttributeHelpers::MethodProvider::Array + - added `delete` and `insert` methods 0.02 Thurs. Sept. 13, 2007 ~~ some misc. doc updates ~~ diff --git a/lib/MooseX/AttributeHelpers/Base.pm b/lib/MooseX/AttributeHelpers/Base.pm index 72cf870..00c3004 100644 --- a/lib/MooseX/AttributeHelpers/Base.pm +++ b/lib/MooseX/AttributeHelpers/Base.pm @@ -190,6 +190,8 @@ C is now required. =over 4 +=item B + =item B =item B diff --git a/lib/MooseX/AttributeHelpers/Collection.pm b/lib/MooseX/AttributeHelpers/Collection.pm index 38af3bd..4623d67 100644 --- a/lib/MooseX/AttributeHelpers/Collection.pm +++ b/lib/MooseX/AttributeHelpers/Collection.pm @@ -87,6 +87,8 @@ Documentation to come. =over 4 +=item B + =item B =item B diff --git a/lib/MooseX/AttributeHelpers/Collection/Array.pm b/lib/MooseX/AttributeHelpers/Collection/Array.pm index ec8c750..f8c9411 100644 --- a/lib/MooseX/AttributeHelpers/Collection/Array.pm +++ b/lib/MooseX/AttributeHelpers/Collection/Array.pm @@ -59,6 +59,8 @@ for more details. =over 4 +=item B + =item B =item B diff --git a/lib/MooseX/AttributeHelpers/Collection/List.pm b/lib/MooseX/AttributeHelpers/Collection/List.pm index f0bbeb0..3d23a8a 100644 --- a/lib/MooseX/AttributeHelpers/Collection/List.pm +++ b/lib/MooseX/AttributeHelpers/Collection/List.pm @@ -59,6 +59,8 @@ for more details. =over 4 +=item B + =item B =item B diff --git a/lib/MooseX/AttributeHelpers/Counter.pm b/lib/MooseX/AttributeHelpers/Counter.pm index 70fe41a..31da9ff 100644 --- a/lib/MooseX/AttributeHelpers/Counter.pm +++ b/lib/MooseX/AttributeHelpers/Counter.pm @@ -96,6 +96,8 @@ above. This allows for a very basic counter definition: =over 4 +=item B + =item B =item B diff --git a/lib/MooseX/AttributeHelpers/Meta/Method/Provided.pm b/lib/MooseX/AttributeHelpers/Meta/Method/Provided.pm index 9c07020..5779b41 100644 --- a/lib/MooseX/AttributeHelpers/Meta/Method/Provided.pm +++ b/lib/MooseX/AttributeHelpers/Meta/Method/Provided.pm @@ -18,6 +18,14 @@ MooseX::AttributeHelpers::Meta::Method::Provided This is an extension of Moose::Meta::Method to mark I methods. +=head1 METHODS + +=over 4 + +=item B + +=back + =head1 BUGS All complex software has bugs lurking in it, and this module is no diff --git a/lib/MooseX/AttributeHelpers/MethodProvider/Array.pm b/lib/MooseX/AttributeHelpers/MethodProvider/Array.pm index 54f0557..5336366 100644 --- a/lib/MooseX/AttributeHelpers/MethodProvider/Array.pm +++ b/lib/MooseX/AttributeHelpers/MethodProvider/Array.pm @@ -1,7 +1,7 @@ package MooseX::AttributeHelpers::MethodProvider::Array; use Moose::Role; -our $VERSION = '0.02'; +our $VERSION = '0.03'; our $AUTHORITY = 'cpan:STEVAN'; with 'MooseX::AttributeHelpers::MethodProvider::List'; @@ -60,13 +60,6 @@ sub shift : method { CORE::shift @{$reader->($_[0])} }; } - -sub clear : method { - my ($attr, $reader, $writer) = @_; - return sub { - @{$reader->($_[0])} = () - }; -} sub get : method { my ($attr, $reader, $writer) = @_; @@ -91,6 +84,37 @@ sub set : method { }; } } + +sub clear : method { + my ($attr, $reader, $writer) = @_; + return sub { + @{$reader->($_[0])} = () + }; +} + +sub delete : method { + my ($attr, $reader, $writer) = @_; + return sub { + CORE::splice @{$reader->($_[0])}, $_[1], 1; + } +} + +sub insert : method { + my ($attr, $reader, $writer) = @_; + if ($attr->has_container_type) { + my $container_type_constraint = $attr->container_type_constraint; + return sub { + ($container_type_constraint->check($_[2])) + || confess "Value " . ($_[2]||'undef') . " did not pass container type constraint"; + splice @{$reader->($_[0])}, $_[1], 0, $_[2]; + }; + } + else { + return sub { + splice @{$reader->($_[0])}, $_[1], 0, $_[2]; + }; + } +} 1; @@ -136,6 +160,10 @@ see those provied methods, refer to that documentation. =item B +=item B + +=item B + =back =head1 BUGS diff --git a/lib/MooseX/AttributeHelpers/Number.pm b/lib/MooseX/AttributeHelpers/Number.pm index 3366a2b..adbc5e0 100644 --- a/lib/MooseX/AttributeHelpers/Number.pm +++ b/lib/MooseX/AttributeHelpers/Number.pm @@ -98,6 +98,8 @@ basic math operations. =over 4 +=item B + =item B =item B