NAME
Check::ISA - DWIM, correct checking of an object's class
SYNOPSIS
use Check::ISA;
if ( obj($foo, "SomeClass") ) {
$foo->some_method;
}
# instead of one of these methods:
UNIVERSAL::isa($foo, "SomeClass") # WRONG
ref $obj eq "SomeClass"; # VERY WRONG
$foo->isa("SomeClass") # May die
local $@; eval { $foo->isa("SomeClass") } # too long
DESCRIPTION
This module provides several functions to assist in testing whether a value is an object, and if so asking about its class.
FUNCTIONS
- obj $thing, [ $class_or_role ]
-
This function tests if
$thingis an object.If
$class_or_roleis provided, it also tests tests whether$thing->DOES($class_or_role)."DOES" in UNIVERSAL is just like
isa, except it's use is encouraged to query about an interface, as opposed to the object structure. IfDOESis not overridden by th ebject, calling it is semantically identical to callingisa.$thingis considered an object if it's blessed, or if it's aGLOBwith a validIOslot (this is a FileHandle object). - inv $thing, [ $class_or_role ]
-
Just like
obj, but also returns true for classes. - obj_can $thing, $method
- inv_can $thing, $method
-
Checks if
$thingis an object or class, and callscanon$thingif appropriate.
VERSION CONTROL
This module is maintained using Darcs. You can get the latest version from http://nothingmuch.woobling.org/code, and use darcs send to commit changes.
AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
COPYRIGHT
Copyright (c) 2008 Yuval Kogman. All rights reserved
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.