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 ~~
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';
CORE::shift @{$reader->($_[0])}
};
}
-
-sub clear : method {
- my ($attr, $reader, $writer) = @_;
- return sub {
- @{$reader->($_[0])} = ()
- };
-}
sub get : method {
my ($attr, $reader, $writer) = @_;
};
}
}
+
+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;
=item B<clear>
+=item B<delete>
+
+=item B<insert>
+
=back
=head1 BUGS