Reflex Special Operators - RapturePlatform/Rapture GitHub Wiki
There are four special operators in Reflex. They are -->
, <--
, -->>
and <<--
. The operators are known as the push, pull, metapush and metapull operators.
Reflex scripts are primarily about taking data from Rapture, manipulating it, and then putting that data back. The push and pull operators can be used to get data from Rapture and to save it back. The meta versions of the pull and push operators return (or deliver) the metadata about the content, such as who wrote the document, its version and when it was written. Only repositories that support metadata can benefit from these meta operators.
As an example, consider a Rapture environment with a repository called "config". The script in the following listing will save some data to Rapture in a configuration document and then later on, retrieve that data and use the information within to control the script. The script also shows an example of initializing a map and writing values to it. When used in this form, the push and pull operators assume a map type on the left hand side and a string on the right.
// Data push and pull
config = {};
config['option1'] = true;
config['level'] = 42;
displayName = '//config/main';
config --> displayName; // Write the map to the document
// Later on in a different script
appConfig <-- displayName;
if appConfig['option1'] do
println("Level is " + appConfig['level']);
else do
println("Option1 is not set');
end
The push and pull operators also work with a file type on the right hand side. For a file, the pull operator returns the contents of the file (as a string) and the push operator writes the string to the file.
The following example yields the output given below the listing:
meta <<-- 'smrs/physical/bond/861594AB5';
println("Meta is " + meta);
With the output
Meta is {version=1,
writeTime=1351614168682,
user=alan,
comment=FeatureInstaller,
deleted=false}