Check::ISA - DWIM, correct checking of an object's class
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
This module provides several functions to assist in testing whether a value is an object, and if so asking about its class.
This function tests if $thing is an object.
$thing
If $class_or_role is provided, it also tests tests whether $thing->DOES($class_or_role).
$class_or_role
$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. If DOES is not overridden by th ebject, calling it is semantically identical to calling isa.
isa
DOES
$thing is considered an object if it's blessed, or if it's a GLOB with a valid IO slot (this is a FileHandle object).
GLOB
IO
Just like obj, but also returns true for classes.
obj
Checks if $thing is an object or class, and calls can on $thing if appropriate.
can
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.
darcs send
Yuval Kogman <nothingmuch@woobling.org>
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.
To install Check::ISA, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Check::ISA
CPAN shell
perl -MCPAN -e shell install Check::ISA
For more information on module installation, please visit the detailed CPAN module installation guide.