1 package # hide me from PAUSE
7 use Scalar::Util 'blessed';
15 my $class = blessed($self) || $self;
16 my $indirect = caller() =~ /^(?:next|maybe::next)$/;
17 my $level = $indirect ? 2 : 1;
19 my ($method_caller, $label, @label);
20 while ($method_caller = (caller($level++))[3]) {
21 @label = (split '::', $method_caller);
30 my $caller = join '::' => @label;
32 $method = $METHOD_CACHE{"$class|$caller|$label"} ||= do {
34 my @MRO = Class::C3::calculateMRO($class);
37 while ($current = shift @MRO) {
38 last if $caller eq $current;
43 foreach my $class (@MRO) {
44 next if (defined $Class::C3::MRO{$class} &&
45 defined $Class::C3::MRO{$class}{methods}{$label});
46 last if (defined ($found = *{$class . '::' . $label}{CODE}));
52 return $method if $indirect;
54 die "No next::method '$label' found for $self" if !$method;
59 sub can { method($_[0]) }
61 package # hide me from PAUSE
67 our $VERSION = '0.02';
69 sub method { (next::method($_[0]) || return)->(@_) }
79 Class::C3::next - Pure-perl next::method and friends
83 This module is used internally by L<Class::C3> when
84 neccesary, and shouldn't be used (or required in
85 distribution dependencies) directly. It
86 defines C<next::method>, C<next::can>, and
87 C<maybe::next::method> in pure perl.
91 Stevan Little, E<lt>stevan@iinteractive.comE<gt>
93 Brandon L. Black, E<lt>blblack@gmail.comE<gt>
95 =head1 COPYRIGHT AND LICENSE
97 Copyright 2005, 2006 by Infinity Interactive, Inc.
99 L<http://www.iinteractive.com>
101 This library is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself.