Dependency of nagios-plugins-nwc-health-8.0-1.1.src.rpm
Name: perl-Safe-Isa
Project: openSUSE_13.2
Repository: oss
Title: Call isa, can, does and DOES safely on things that may not be objects
Description:
How many times have you found yourself writing:
if ($obj->isa('Something')) {
and then shortly afterwards cursing and changing it to:
if (Scalar::Util::blessed($obj) and $obj->isa('Something')) {
Right. That's why this module exists.
Since perl allows us to provide a subroutine reference or a method name to
the -> operator when used as a method call, and a subroutine doesn't
require the invocant to actually be an object, we can create safe versions
of isa, can and friends by using a subroutine reference that only tries to
call the method if it's used on an object. So:
my $isa_Foo = $maybe_an_object->$_call_if_object(isa => 'Foo');
is equivalent to
my $isa_Foo = do {
if (Scalar::Util::blessed($maybe_an_object)) {
$maybe_an_object->isa('Foo');
} else {
undef;
}
};
Note that we don't handle trying class names, because many things are valid
class names that you might not want to treat as one (like say "Matt") - the
'is_module_name' function from the Module::Runtime manpage is a good way to
check for something you might be able to call methods on if you want to do
that.
Version: 1.000005
Release: 1.2
Architecture: noarch
Size: 10.9 KB
Build Time: 2014-10-06 15:17:53 +0200 (over 9 years ago)
Provides
Symbol | Required by |
---|---|
perl(Safe::Isa) = 1.000005 | perl-HTTP-Thin |
perl-Safe-Isa = 1.000005-1.2 |
Requires
Symbol | Provided by |
---|---|
perl(:MODULE_COMPAT_5.20.1) | perl |