$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-my $get_arrayref = sub {
+sub _get_arrayref {
my $val = $_[1]->( $_[0] );
unless ( _ARRAY0($val) ) {
}
return $val;
-};
+}
sub count : method {
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- scalar @{ $get_arrayref->( $_[0], $reader, $name ) };
+ scalar @{ _get_arrayref( $_[0], $reader, $name ) };
};
}
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- scalar @{ $get_arrayref->( $_[0], $reader, $name ) } ? 0 : 1;
+ scalar @{ _get_arrayref( $_[0], $reader, $name ) } ? 0 : 1;
};
}
my $name = $attr->name;
return sub {
my ( $instance, $predicate ) = @_;
- List::Util::first { $predicate->() } @{ $get_arrayref->( $instance, $reader, $name ) };
+ List::Util::first { $predicate->() } @{ _get_arrayref( $instance, $reader, $name ) };
};
}
my $name = $attr->name;
return sub {
my ( $instance, $f ) = @_;
- CORE::map { $f->() } @{ $get_arrayref->( $instance, $reader, $name ) };
+ CORE::map { $f->() } @{ _get_arrayref( $instance, $reader, $name ) };
};
}
return sub {
my ( $instance, $f ) = @_;
our ($a, $b);
- List::Util::reduce { $f->($a, $b) } @{ $get_arrayref->( $instance, $reader, $name ) };
+ List::Util::reduce { $f->($a, $b) } @{ _get_arrayref( $instance, $reader, $name ) };
};
}
# which defines the coderef is compiled, before we even get a
# chance to see it here. So, we have no real choice but to use
# normal parameters. --doy
- CORE::sort { $predicate->( $a, $b ) } @{ $get_arrayref->( $instance, $reader, $name ) };
+ CORE::sort { $predicate->( $a, $b ) } @{ _get_arrayref( $instance, $reader, $name ) };
}
else {
- CORE::sort @{ $get_arrayref->( $instance, $reader, $name ) };
+ CORE::sort @{ _get_arrayref( $instance, $reader, $name ) };
}
};
}
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- List::Util::shuffle @{ $get_arrayref->( $_[0], $reader, $name ) };
+ List::Util::shuffle @{ _get_arrayref( $_[0], $reader, $name ) };
};
}
my $name = $attr->name;
return sub {
my ( $instance, $predicate ) = @_;
- CORE::grep { $predicate->() } @{ $get_arrayref->( $instance, $reader, $name ) };
+ CORE::grep { $predicate->() } @{ _get_arrayref( $instance, $reader, $name ) };
};
}
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- List::MoreUtils::uniq @{ $get_arrayref->( $_[0], $reader, $name ) };
+ List::MoreUtils::uniq @{ _get_arrayref( $_[0], $reader, $name ) };
};
}
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- @{ $get_arrayref->( $_[0], $reader, $name ) };
+ @{ _get_arrayref( $_[0], $reader, $name ) };
};
}
my $name = $attr->name;
return sub {
my ( $instance, $separator ) = @_;
- join $separator, @{ $get_arrayref->( $instance, $reader, $name ) };
+ join $separator, @{ _get_arrayref( $instance, $reader, $name ) };
};
}
. " did not pass container type constraint '$container_type_constraint'"
foreach @_;
- CORE::push @{ $get_arrayref->( $instance, $reader, $name ) } => @_;
+ CORE::push @{ _get_arrayref( $instance, $reader, $name ) } => @_;
};
}
else {
return sub {
my $instance = CORE::shift;
- CORE::push @{ $get_arrayref->( $instance, $reader, $name ) } => @_;
+ CORE::push @{ _get_arrayref( $instance, $reader, $name ) } => @_;
};
}
}
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- CORE::pop @{ $get_arrayref->( $_[0], $reader, $name ) };
+ CORE::pop @{ _get_arrayref( $_[0], $reader, $name ) };
};
}
. ( $_ || 'undef' )
. " did not pass container type constraint '$container_type_constraint'"
foreach @_;
- CORE::unshift @{ $get_arrayref->( $instance, $reader, $name ) } => @_;
+ CORE::unshift @{ _get_arrayref( $instance, $reader, $name ) } => @_;
};
}
else {
return sub {
my $instance = CORE::shift;
- CORE::unshift @{ $get_arrayref->( $instance, $reader, $name ) } => @_;
+ CORE::unshift @{ _get_arrayref( $instance, $reader, $name ) } => @_;
};
}
}
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- CORE::shift @{ $get_arrayref->( $_[0], $reader, $name ) };
+ CORE::shift @{ _get_arrayref( $_[0], $reader, $name ) };
};
}
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- $get_arrayref->( $_[0], $reader, $name )->[ $_[1] ];
+ _get_arrayref( $_[0], $reader, $name )->[ $_[1] ];
};
}
|| confess "Value "
. ( $_[2] || 'undef' )
. " did not pass container type constraint '$container_type_constraint'";
- $get_arrayref->( $_[0], $reader, $name )->[ $_[1] ] = $_[2];
+ _get_arrayref( $_[0], $reader, $name )->[ $_[1] ] = $_[2];
};
}
else {
return sub {
- $get_arrayref->( $_[0], $reader, $name )->[ $_[1] ] = $_[2];
+ _get_arrayref( $_[0], $reader, $name )->[ $_[1] ] = $_[2];
};
}
}
my $self = shift;
if ( @_ == 1 ) { # reader
- return $get_arrayref->( $self, $reader, $name )->[ $_[0] ];
+ return _get_arrayref( $self, $reader, $name )->[ $_[0] ];
}
elsif ( @_ == 2 ) { # writer
( $container_type_constraint->check( $_[1] ) )
|| confess "Value "
. ( $_[1] || 'undef' )
. " did not pass container type constraint '$container_type_constraint'";
- $get_arrayref->( $self, $reader, $name )[ $_[0] ] = $_[1];
+ _get_arrayref( $self, $reader, $name )->[ $_[0] ] = $_[1];
}
else {
confess "One or two arguments expected, not " . @_;
my $self = shift;
if ( @_ == 1 ) { # reader
- return $get_arrayref->( $self, $reader, $name )->[ $_[0] ];
+ return _get_arrayref( $self, $reader, $name )->[ $_[0] ];
}
elsif ( @_ == 2 ) { # writer
- $get_arrayref->( $self, $reader, $name )->[ $_[0] ] = $_[1];
+ _get_arrayref( $self, $reader, $name )->[ $_[0] ] = $_[1];
}
else {
confess "One or two arguments expected, not " . @_;
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- @{ $get_arrayref->( $_[0], $reader, $name ) } = ();
+ @{ _get_arrayref( $_[0], $reader, $name ) } = ();
};
}
my ( $attr, $reader, $writer ) = @_;
my $name = $attr->name;
return sub {
- CORE::splice @{ $get_arrayref->( $_[0], $reader, $name ) }, $_[1], 1;
+ CORE::splice @{ _get_arrayref( $_[0], $reader, $name ) }, $_[1], 1;
};
}
|| confess "Value "
. ( $_[2] || 'undef' )
. " did not pass container type constraint '$container_type_constraint'";
- CORE::splice @{ $get_arrayref->( $_[0], $reader, $name ) }, $_[1], 0, $_[2];
+ CORE::splice @{ _get_arrayref( $_[0], $reader, $name ) }, $_[1], 0, $_[2];
};
}
else {
return sub {
- CORE::splice @{ $get_arrayref->( $_[0], $reader, $name ) }, $_[1], 0, $_[2];
+ CORE::splice @{ _get_arrayref( $_[0], $reader, $name ) }, $_[1], 0, $_[2];
};
}
}
. ( defined($_) ? $_ : 'undef' )
. " did not pass container type constraint '$container_type_constraint'"
for @elems;
- CORE::splice @{ $get_arrayref->( $self, $reader, $name ) }, $i, $j, @elems;
+ CORE::splice @{ _get_arrayref( $self, $reader, $name ) }, $i, $j, @elems;
};
}
else {
return sub {
my ( $self, $i, $j, @elems ) = @_;
- CORE::splice @{ $get_arrayref->( $self, $reader, $name ) }, $i, $j, @elems;
+ CORE::splice @{ _get_arrayref( $self, $reader, $name ) }, $i, $j, @elems;
};
}
}
my @sorted;
if ($predicate) {
@sorted =
- CORE::sort { $predicate->( $a, $b ) } @{ $get_arrayref->( $instance, $reader, $name ) };
+ CORE::sort { $predicate->( $a, $b ) } @{ _get_arrayref( $instance, $reader, $name ) };
}
else {
- @sorted = CORE::sort @{ $get_arrayref->( $instance, $reader, $name ) };
+ @sorted = CORE::sort @{ _get_arrayref( $instance, $reader, $name ) };
}
$writer->( $instance, \@sorted );
my $name = $attr->name;
return sub {
my ( $instance, $n, $f ) = @_;
- my $it = List::MoreUtils::natatime($n, @{ $get_arrayref->( $instance, $reader, $name ) });
+ my $it = List::MoreUtils::natatime($n, @{ _get_arrayref( $instance, $reader, $name ) });
return $it unless $f;
while (my @vals = $it->()) {