ryanwood / shade

Shade is a state machine (or workflow) engine for ColdFusion business objects.

shade / State.cfc
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 1 <cfcomponent displayname="State" output="false">
4245d4bd » ryanwood 2008-07-18 Clean up 2
3 <cfset instance = structNew() />
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 4
5 <cffunction name="init" access="public" output="false">
6 <cfargument name="name" type="string" required="true" />
7 <cfscript>
8 instance.name = arguments.name;
9 </cfscript>
10 <cfreturn this />
11 </cffunction>
12
13 <cffunction name="getName" returntype="string" access="public" output="false">
14 <cfreturn instance.name />
15 </cffunction>
16
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 17 <cffunction name="before" returntype="boolean" access="public" output="false">
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 18 <cfargument name="obj" required="true" />
4c22d15f » ryanwood 2008-09-12 Added global event callback... 19 <cfset invokeCallback('beforeAction', arguments.obj) />
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 20 <cfreturn invokeCallback('before#getName()#Action', arguments.obj) />
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 21 </cffunction>
22
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 23 <cffunction name="after" returntype="void" access="public" output="false">
4c22d15f » ryanwood 2008-09-12 Added global event callback... 24 <cfargument name="obj" required="true" />
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 25 <cfset invokeCallback('after#getName()#Action', arguments.obj) />
4c22d15f » ryanwood 2008-09-12 Added global event callback... 26 <cfset invokeCallback('afterAction', arguments.obj) />
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 27 </cffunction>
28
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 29 <cffunction name="exit" returntype="void" access="public" output="false">
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 30 <cfargument name="obj" required="true" />
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 31 <cfset invokeCallback('exit#getName()#Action', arguments.obj) />
4c22d15f » ryanwood 2008-09-12 Added global event callback... 32 <cfset invokeCallback('exitAction', arguments.obj) />
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 33 </cffunction>
34
4245d4bd » ryanwood 2008-07-18 Clean up 35 <cffunction name="invokeCallback" returntype="boolean" access="private" output="false">
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 36 <cfargument name="callback" type="string" required="true" />
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 37 <cfargument name="obj" required="true" />
435c5762 » ryanwood 2008-07-17 Added query methods and eve... 38 <cfif structKeyExists(arguments.obj, arguments.callback)>
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 39 <cfinvoke component="#arguments.obj#" method="#arguments.callback#" returnvariable="result" />
40 <cfif isDefined('result') and isBoolean(result)>
41 <cfreturn result />
42 </cfif>
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 43 </cfif>
94ee712c » ryanwood 2008-07-18 Added License. Changed 'ent... 44 <cfreturn true />
50b21454 » ryanwood 2008-07-17 Initial Commit part 2 45 </cffunction>
46
47 </cfcomponent>