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

This function tests if $thing is an object. If $class is provided, it also tests tests whether \*(C`$thing->isa($class)\*(C'. $thing is considered an object if it's blessed, or if it's a \*(C`GLOB\*(C' with a valid \*(C`IO\*(C' slot (the \*(C`IO\*(C' slot contains a FileHandle object which is the actual invocant). This corresponds directly to \*(C`gv_fetchmethod\*(C'. Just like \*(C`obj\*(C' but uses \*(L"\s-1DOES\s0\*(R" in \s-1UNIVERSAL\s0 instead of \*(L"isa\*(R" in \s-1UNIVERSAL\s0. \*(L"\s-1DOES\s0\*(R" in \s-1UNIVERSAL\s0 is just like \*(C`isa\*(C', except it's use is encouraged to query about an interface, as opposed to the object structure. If \*(C`DOES\*(C' is not overridden by th ebject, calling it is semantically identical to calling \*(C`isa\*(C'. This is probably reccomended over \*(C`obj\*(C' for interoperability, but can be slower on Perls before 5.10. Note that \*(L"\s-1DOES\s0\*(R" in \s-1UNIVERSAL\s0 Just like \*(C`obj_does\*(C', but also returns true for classes. Note that this method is slower, but is supposed to return true for any value you can call methods on (class, object, filehandle, etc). Look into autobox if you would like to be able to call methods on all values. Checks if $thing is an object or class, and calls \*(C`can\*(C' on $thing if appropriate.

RELATED TO Check::ISA…

\s-1UNIVERSAL\s0, Params::Util, autobox, Moose, asa

VERSION CONTROL

This module is maintained using Darcs. You can get the latest version from <http://nothingmuch.woobling.org/code>, and use \*(C`darcs send\*(C' to commit changes.

AUTHOR

Yuval Kogman <[email protected]>

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.