Forked from mccrackend/Calculated InitialExpression
Created
October 21, 2015 11:56
-
-
Save mnjstwins/ca313b29ca4b90dc14f8 to your computer and use it in GitHub Desktop.
Using a calculated value for a property's InitialExpression. Written in Intersystems Cache Object Script.
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
...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