Class-Multi
view release on metacpan or search on metacpan
}
# if something nonzero was returned, the loop is done
return $rc if $rc;
}
return undef;
};
sub walk_width(&$;@) {
&$walk_raw( 1, @_ );
}
sub walk_depth(&$;@) {
&$walk_raw( 0, @_ );
}
sub walk(&$;@) {
confess( "Class::Multi::walk is deprecated. Use walk_width or walk_depth instead.\n" );
&$walk_raw( 0, @_ );
}
sub walk_width_up(&$;@) {
my ( $callout, $derived, @avoid ) = @_;
my @classes;
walk_width { push @classes, $_; 0 } $derived, @avoid;
my $rc;
while ( my $class = pop @classes ) {
# call the given code reference
local $_ = $class;
C<other> checks if the object or class $this has a method called 'METHOD',
that occurs -AFTER- the calling class in the inheritance tree.
Usage and semantics are otherwise identical to C<UNIVERSAL::can>
The calling class is inferred via C<caller()>.
=cut
sub other($$) {
my ( $this, $name ) = @_;
my ( $origin, $caller );
# a valid class or instance must be supplied
$origin = ref( $this ) || $this or return;
# we must be called from code that has a package reference
$caller = caller() or return;
no strict 'refs';
} $origin, $caller;
}
=head2 C<< otherpkg( $this, METHOD ) >>
Identical to C<other>, except the package name is returned instead of
the desired method's code reference.
=cut
sub otherpkg($$) {
my ( $this, $name ) = @_;
my ( $origin, $caller );
# a valid class or instance must be supplied
$origin = ref( $this ) || $this or return;
# we must be called from code that has a package reference
$caller = caller() or return;
no strict 'refs';
=head2 C<< otherrun( $this, METHOD, @myargs ) >>
Identical to C<other>, except the function is run and its result returned
instead of the desired method's code reference.
Equivalent to C<< &{other( $this, METHOD )}( $this, @myargs ); >>.
=cut
sub otherrun($$) {
my $this = shift;
my $name = shift;
my ( $origin, $caller, $func );
# a valid class or instance must be supplied
$origin = ref( $this ) || $this or return;
# we must be called from code that has a package reference
$caller = caller() or return;
( run in 0.920 second using v1.01-cache-2.11-cpan-1f129e94a17 )