Array-Iterator
view release on metacpan or search on metacpan
lib/Array/Iterator.pm view on Meta::CPAN
=head2 _current_index
An lvalue-ed subroutine that allows access to the iterator's internal pointer.
This can be used in a subclass to access the value.
=cut
# We need to alter this so it's an lvalue
sub _current_index : lvalue {
(UNIVERSAL::isa((caller)[0], __PACKAGE__))
|| die 'Illegal Operation: This method can only be called by a subclass';
$_[0]->{_current_index}
}
=head2 _iteratee
This returns the item being iterated over, in our case an array.
=cut
# This we should never need to alter so we don't make it a lvalue
sub _iteratee {
(UNIVERSAL::isa((caller)[0], __PACKAGE__))
|| die 'Illegal Operation: This method can only be called by a subclass';
$_[0]->{_iteratee}
}
# we move this from a private method
# to a protected one, and check our access
# as well
sub _getItem {
(UNIVERSAL::isa((caller)[0], __PACKAGE__)) || die 'Illegal Operation: This method can only be called by a subclass';
my ($self, $iteratee, $index) = @_;
return $iteratee->[$index];
}
=head2 _get_item ($iteratee, $index)
This method is used by all other routines to access items. Given the iteratee
and an index, it will return the item being stored in the C<$iteratee> at the index
of C<$index>.
=cut
sub _get_item { my $self = shift; $self->_getItem(@_) }
# we need to alter this so it's an lvalue
sub _iterated : lvalue {
(UNIVERSAL::isa((caller)[0], __PACKAGE__))
|| die 'Illegal Operation: This method can only be called by a subclass';
$_[0]->{_iterated}
}
=head2 iterated
Access to the _iterated status, for subclasses
=cut
( run in 0.471 second using v1.01-cache-2.11-cpan-a3c8064c92c )