.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Check::ISA 3pm" .TH Check::ISA 3pm "2022-06-10" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Check::ISA \- DWIM, correct checking of an object's class. .SH "VERSION" .IX Header "VERSION" Version 0.09 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& 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 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides several functions to assist in testing whether a value is an object, and if so asking about its class. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .ie n .IP "obj $thing, [ $class ]" 4 .el .IP "obj \f(CW$thing\fR, [ \f(CW$class\fR ]" 4 .IX Item "obj $thing, [ $class ]" This function tests if \f(CW$thing\fR is an object. .Sp If \f(CW$class\fR is provided, it also tests tests whether \f(CW\*(C`$thing\->isa($class)\*(C'\fR. .Sp \&\f(CW$thing\fR is considered an object if it's blessed or a \f(CW\*(C`GLOB\*(C'\fR with a valid \f(CW\*(C`IO\*(C'\fR slot (the \f(CW\*(C`IO\*(C'\fR slot contains a FileHandle object which is the actual invocant). This corresponds directly to \f(CW\*(C`gv_fetchmethod\*(C'\fR. .ie n .IP "obj_does $thing, [ $class_or_role ]" 4 .el .IP "obj_does \f(CW$thing\fR, [ \f(CW$class_or_role\fR ]" 4 .IX Item "obj_does $thing, [ $class_or_role ]" Just like \f(CW\*(C`obj\*(C'\fR but uses \*(L"\s-1DOES\*(R"\s0 in \s-1UNIVERSAL\s0 instead of \*(L"isa\*(R" in \s-1UNIVERSAL\s0. .Sp \&\*(L"\s-1DOES\*(R"\s0 in \s-1UNIVERSAL\s0 is just like \f(CW\*(C`isa\*(C'\fR except it's use is encouraged to query about an interface, as opposed to the object structure. If \f(CW\*(C`DOES\*(C'\fR is not overridden by the ebject, calling it is semantically identical to calling \f(CW\*(C`isa\*(C'\fR. .Sp This is probably reccomended over \f(CW\*(C`obj\*(C'\fR for interoperability but can be slower on Perls before 5.10. .Sp Note that \*(L"\s-1DOES\*(R"\s0 in \s-1UNIVERSAL\s0 .ie n .IP "inv $thing, [ $class_or_role ]" 4 .el .IP "inv \f(CW$thing\fR, [ \f(CW$class_or_role\fR ]" 4 .IX Item "inv $thing, [ $class_or_role ]" Just like \f(CW\*(C`obj_does\*(C'\fR, but also returns true for classes. .Sp Note that this method is slower, but is supposed to return true for any value you can call methods on (class, object, filehandle, etc). .Sp Look into autobox if you would like to be able to call methods on all values. .ie n .IP "obj_can $thing, $method" 4 .el .IP "obj_can \f(CW$thing\fR, \f(CW$method\fR" 4 .IX Item "obj_can $thing, $method" .PD 0 .ie n .IP "inv_can $thing, $method" 4 .el .IP "inv_can \f(CW$thing\fR, \f(CW$method\fR" 4 .IX Item "inv_can $thing, $method" .PD Checks if \f(CW$thing\fR is an object or class, and calls \f(CW\*(C`can\*(C'\fR on \f(CW$thing\fR if appropriate. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1UNIVERSAL\s0, Params::Util, autobox, Moose, asa .SH "REPOSITORY" .IX Header "REPOSITORY" .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-check\-isa at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Check::ISA .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker (report bugs here) .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "AUTHOR" .IX Header "AUTHOR" Yuval Kogman .PP Currently maintained by Mohammad S Anwar (\s-1MANWAR\s0), \f(CW\*(C`\*(C'\fR .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright (c) 2008 Yuval Kogman. .PP Copyright (c) 2016 Mohammad S Anwar. .PP All rights reserved. This program is free software; you can redistribute it and / or modify it under the same terms as Perl itself. .PP Any use, modification, and distribution of the Standard or Modified Versions is governed by this License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. .PP If your Modified Version has been derived from a Modified Version made by someone other than you,you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. .PP This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. .PP This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this License to you shall terminate on the date that such litigation is filed. .PP Disclaimer of Warranty: \s-1THE\s0 \s-1PACKAGE\s0 \s-1IS\s0 \s-1PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS\s0 "\s-1AS IS\s0' \s-1AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES\s0 \s-1OF\s0 \s-1MERCHANTABILITY,\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE, OR\s0 NON-INFRINGEMENT \s-1ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\s0 \s-1OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0