-
-
Save nolandubeau/25da0d626d62bdd00748 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="serializeObject" output="false" access="public" returntype="any" hint="Serialize an object and optionally save it into a file."> | |
<cfargument name="target" type="any" required="true" hint="The complex object, such as a query or CFC, that will be serialized."/> | |
<cfargument name="filePath" type="string" required="false" hint="The path of the file in which to save the serialized data."/> | |
<cfargument name="algorithm" type="string" required="false" default="" hint="Override the instance algorithm."/> | |
<cfscript> | |
var binaryData = ""; | |
if(len(trim(arguments.algorithm))){ | |
local.algorithm = arguments.algorithm; | |
}else{ | |
local.algorithm = instance.algorithm; | |
} | |
// Which algorithm to use? | |
switch(local.algorithm){ | |
case "generic" : { | |
binaryData = serializeGeneric(arguments.target); | |
break; | |
} | |
case "railo" : { | |
binaryData = serializeRailo(arguments.target); | |
break; | |
} | |
case "objectSave" : { | |
binaryData = serializeWithObjectSave(arguments.target); | |
break; | |
} | |
} | |
// Save to File? | |
if( structKeyExists(arguments,"filePath") ){ | |
saveToFile(arguments.filePath,binaryData); | |
} | |
return binaryData; | |
</cfscript> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment