1Check::ISA(3)         User Contributed Perl Documentation        Check::ISA(3)
2
3
4

NAME

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

SYNOPSIS

9               use Check::ISA;
10
11               if ( obj($foo, "SomeClass") ) {
12                       $foo->some_method;
13               }
14
15
16               # instead of one of these methods:
17               UNIVERSAL::isa($foo, "SomeClass") # WRONG
18               ref $obj eq "SomeClass"; # VERY WRONG
19               $foo->isa("SomeClass") # May die
20               local $@; eval { $foo->isa("SomeClass") } # too long
21

DESCRIPTION

23       This module provides several functions to assist in testing whether a
24       value is an object, and if so asking about its class.
25

FUNCTIONS

27       obj $thing, [ $class ]
28           This function tests if $thing is an object.
29
30           If $class is provided, it also tests tests whether
31           "$thing->isa($class)".
32
33           $thing is considered an object if it's blessed, or if it's a "GLOB"
34           with a valid "IO" slot (the "IO" slot contains a FileHandle object
35           which is the actual invocant). This corresponds directly to
36           "gv_fetchmethod".
37
38       obj_does $thing, [ $class_or_role ]
39           Just like "obj" but uses "DOES" in UNIVERSAL instead of "isa" in
40           UNIVERSAL.
41
42           "DOES" in UNIVERSAL is just like "isa", except it's use is
43           encouraged to query about an interface, as opposed to the object
44           structure. If "DOES" is not overridden by th ebject, calling it is
45           semantically identical to calling "isa".
46
47           This is probably reccomended over "obj" for interoperability, but
48           can be slower on Perls before 5.10.
49
50           Note that "DOES" in UNIVERSAL
51
52       inv $thing, [ $class_or_role ]
53           Just like "obj_does", but also returns true for classes.
54
55           Note that this method is slower, but is supposed to return true for
56           any value you can call methods on (class, object, filehandle, etc).
57
58           Look into autobox if you would like to be able to call methods on
59           all values.
60
61       obj_can $thing, $method
62       inv_can $thing, $method
63           Checks if $thing is an object or class, and calls "can" on $thing
64           if appropriate.
65

SEE ALSO

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

VERSION CONTROL

70       This module is maintained using Darcs. You can get the latest version
71       from <http://nothingmuch.woobling.org/code>, and use "darcs send" to
72       commit changes.
73

AUTHOR

75       Yuval Kogman <nothingmuch@woobling.org>
76
78               Copyright (c) 2008 Yuval Kogman. All rights reserved
79               This program is free software; you can redistribute
80               it and/or modify it under the same terms as Perl itself.
81
82
83
84perl v5.12.0                      2008-07-25                     Check::ISA(3)
Impressum