GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CHECK::ISA (3)

.ds Aq ’

NAME

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

CONTENTS

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

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 if it’s 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 th 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.

SEE ALSO

UNIVERSAL, 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 darcs send to commit changes.

AUTHOR

Yuval Kogman <nothingmuch@woobling.org>

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.



Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CHECK::ISA (3) 2008-07-25

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.