1 package # hide me from PAUSE
6 no warnings 'redefine'; # for 00load.t w/ core support
8 use Scalar::Util 'blessed';
10 our $VERSION = '0.24';
16 my $class = blessed($self) || $self;
17 my $indirect = caller() =~ /^(?:next|maybe::next)$/;
18 my $level = $indirect ? 2 : 1;
20 my ($method_caller, $label, @label);
21 while ($method_caller = (caller($level++))[3]) {
22 @label = (split '::', $method_caller);
31 my $caller = join '::' => @label;
33 $method = $METHOD_CACHE{"$class|$caller|$label"} ||= do {
35 my @MRO = Class::C3::calculateMRO($class);
38 while ($current = shift @MRO) {
39 last if $caller eq $current;
44 foreach my $class (@MRO) {
45 next if (defined $Class::C3::MRO{$class} &&
46 defined $Class::C3::MRO{$class}{methods}{$label});
47 last if (defined ($found = *{$class . '::' . $label}{CODE}));
53 return $method if $indirect;
55 die "No next::method '$label' found for $self" if !$method;
60 sub can { method($_[0]) }
62 package # hide me from PAUSE
67 no warnings 'redefine'; # for 00load.t w/ core support
69 our $VERSION = '0.24';
71 sub method { (next::method($_[0]) || return)->(@_) }
81 Class::C3::next - Pure-perl next::method and friends
85 This module is used internally by L<Class::C3> when
86 necessary, and shouldn't be used (or required in
87 distribution dependencies) directly. It
88 defines C<next::method>, C<next::can>, and
89 C<maybe::next::method> in pure perl.
93 Stevan Little, E<lt>stevan@iinteractive.comE<gt>
95 Brandon L. Black, E<lt>blblack@gmail.comE<gt>
97 =head1 COPYRIGHT AND LICENSE
99 Copyright 2005, 2006 by Infinity Interactive, Inc.
101 L<http://www.iinteractive.com>
103 This library is free software; you can redistribute it and/or modify
104 it under the same terms as Perl itself.