- You can now make a closure from a text expression - if the factory doesn't find return and ; in the code block it will add them automatically.
- The call() method is automatically an alias for the generated function which means that if you provide an argument specification, you no longer have to use named arguments in the method call.
- The code examples have been updated to better illustrate the equivalent of the Ruby select / filter example on Fowler's bliki (link posted by Peter Bell on the previous entry)
I modified your ClosureFactor.cfc file as shown below to do this and it's working.
<cfset variables.baseFilePath = "" /><!--- Base file path to org/corfield/closure directory NO TRAILING SLASH --->
<cffunction name="init" returntype="org.corfield.closure.ClosureFactory" > <cfargument name="baseFilePath" type="string" required="true" >
<cfset variables.baseFilePath = arguments.baseFilePath >
<cfreturn this > </cffunction>
(in makeClosureFromString) ..... <!--- synthesize a unique function name: ---> <cfset functionName = "_" & replace(createUUID(),"-","","all") /> <cfset filePath = variables.baseFilePath & "/" & functionName /> <!--- if the code seems to be script code, wrap it in a cfscript tag: ---> ......
and of course the fall to the ClosureFactory becomes:
<cfset cf = createObject("component", "org.corfield.closure.ClosureFactory").init( "<<< physical path to /org/corfield/closure >>>" ) >


