Skip to content

Instantly share code, notes, and snippets.

@mccrackend
Created October 10, 2011 20:00
Show Gist options
  • Save mccrackend/1276360 to your computer and use it in GitHub Desktop.
Save mccrackend/1276360 to your computer and use it in GitHub Desktop.
Using a calculated value for a property's InitialExpression. Written in Intersystems Cache Object Script.
...class definition
/// Set InitialExpression to any class method returning the calculated value.
/// In this case, I'm returning a string value.
Property BaseDirectoryPath As %String [ InitialExpression = {..GetBaseDirectoryForNamespace()} ];
/// Returns the base directory path to use for whatever cache instance the class is being used in.
ClassMethod GetBaseDirectoryForNamespace() As %String
{
SET vPath = $CASE($Namespace,
"MCCRDA":"/home/mccrda/stage/control/",
"STAGE":"/home/ensemble/stage/control/",
"PROD":"/home/ensemble/prod/control/",
"PROD2":"/home/ensemble2/prod2/control",
:"/home/raczta/stage/control/")
Quit vPath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment