Add method resolution discovery in SNMP::Info::MRO helper module

This commit is contained in:
Oliver Gorwits
2014-06-19 15:44:51 +01:00
parent 827398228c
commit f7430ab1a6
2 changed files with 1 additions and 51 deletions

View File

@@ -4,7 +4,7 @@ version 3.16
[ENHANCEMENTS] [ENHANCEMENTS]
* Add superclass discovery methods (super_path and print_super_path) * Add method resolution discovery in SNMP::Info::MRO helper module
version 3.15 (2014-07-10) version 3.15 (2014-07-10)

50
Info.pm
View File

@@ -1223,56 +1223,6 @@ sub new {
return $auto_specific ? $new_obj->specify() : $new_obj; return $auto_specific ? $new_obj->specify() : $new_obj;
} }
=item super_path()
Returns the list (in order) of the names of classes Perl will search to find
methods for this SNMP::Info class or object instance.
Can be called as either a class or object method:
# class method:
my @list = SNMP::Info::Layer3::Juniper->super_path();
# object method:
my @list = $info->super_path();
Note this B<requires> the L<Class:ISA> distribution to be installed.
=cut
sub super_path {
my $self = shift;
my $class = (ref $self ? ref $self : $self);
# Load Class::ISA, if we can
eval { require Class::ISA }; ## no critic
if ($@) {
croak "SNMP::Info::super_path() Failed to load Class::ISA (is it installed?). $@\n";
}
else {
return Class::ISA::self_and_super_path( $class );
}
}
=item print_super_path()
Prints the list (in order) of the names of classes Perl will search to find
methods for this SNMP::Info class or object instance.
Can be called as either a class or object method:
# class method:
SNMP::Info::Layer3::Juniper->print_super_path();
# object method:
$info->print_super_path();
Note this B<requires> the L<Class:ISA> distribution to be installed.
=cut
sub print_super_path {
print join ("\n", (shift)->super_path), "\n";
}
=item update() =item update()
Replace the existing session with a new one with updated values, Replace the existing session with a new one with updated values,