Overkill?  Because it's more flexible, or because it's less code? 
Here's a reimplemented instanceOf method (the only change is the new
predicate on line 9).  Definitely simpler than adding three new
methods to your classes, and then adding more code to your init method
to use them.  Especially since you'll probably need the instanceOf
method anyway for doing superclass checking.

<cffunction name="instanceOf" access="public" output="false"
returntype="boolean"
        hint="I return whether this object is an instance of the specified 
type">
        <cfargument name="type" type="string" required="true" />
        <cfset var md = getMetaData() />
        <cfset var curr = md />
        <cfif NOT structKeyExists(md, "instanceOf_" & type)>
                <cfset md["instanceOf_" & type] = false />
                <cfloop condition="true">
                        <cfif curr.name EQ type OR ( structKeyExists(curr, 
"implements")
AND listFindNoCase(curr.implements, type) GT 0 )>
                                <cfset md["instanceOf_" & type] = true />
                                <cfbreak />
                        </cfif>
                        <cfif NOT structKeyExists(curr, "extends")>
                                <cfbreak />
                        </cfif>
                        <cfset curr = curr.extends />
                </cfloop>
        </cfif>
        <cfreturn md["instanceOf_" & type] />
</cffunction>

On Apr 6, 2005 2:13 PM, Roland Collins <[EMAIL PROTECTED]> wrote:
> Right, but I think it's overkill in this case :)

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]


Reply via email to