logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Check::ISA - DWIM, correct checking of an object's class.

Author

       Yuval Kogman <nothingmuch@woobling.org>

       Currently maintained by Mohammad S Anwar (MANWAR), "<mohammad.anwar at yahoo.com>"

Bugs

       Please  report  any  bugs  or  feature  requests  to  "bug-check-isa at rt.cpan.org",  or through the web
       interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Check-ISA>.  I will  be  notified  and  then
       you'll automatically be notified of progress on your bug as I make changes.

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 ]
           This function tests if $thing is an object.

           If $class is provided, it also tests tests whether "$thing->isa($class)".

           $thing  is  considered  an  object  if it's blessed or a "GLOB" with a valid "IO" slot (the "IO" slot
           contains  a  FileHandle  object  which  is  the  actual  invocant).   This  corresponds  directly  to
           "gv_fetchmethod".

       obj_does $thing, [ $class_or_role ]
           Just like "obj" but uses "DOES" in UNIVERSAL instead of "isa" in UNIVERSAL.

           "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  the  ebject,  calling  it  is
           semantically identical to calling "isa".

           This is probably reccomended over "obj" for interoperability but can be slower on Perls before 5.10.

           Note that "DOES" in UNIVERSAL

       inv $thing, [ $class_or_role ]
           Just like "obj_does", 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.

       obj_can $thing, $method
       inv_can $thing, $method
           Checks if $thing is an object or class, and calls "can" on $thing if appropriate.

Name

       Check::ISA - DWIM, correct checking of an object's class.

Repository

       <https://github.com/manwar/Check-ISA>

See Also

       UNIVERSAL, Params::Util, autobox, Moose, asa

Support

       You can find documentation for this module with the perldoc command.

           perldoc Check::ISA

       You can also look for information at:

       •   RT: CPAN's request tracker (report bugs here)

           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Check-ISA>

       •   AnnoCPAN: Annotated CPAN documentation

           <http://annocpan.org/dist/Check-ISA>

       •   CPAN Ratings

           <http://cpanratings.perl.org/d/Check-ISA>

       •   Search CPAN

           <http://search.cpan.org/dist/Check-ISA/>

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

Version

       Version 0.09

See Also