Meta/1

Use the Meta/1 function in an expressions list to extract and use metadata, like the owner of a mix or a mix component, or the name of a user.

<request name="Sign"
  service="Expr"
  fields="SIGN">
  <prop name="expr.src"
    content-type="text/x-erlang"><![CDATA[
User = Meta(user),
put("signature", User),
"Ok".
  ]]></prop>
  <reply name="Ok"
    fields="signature"/>
</request>

Meta arguments

The user argument is only available for operations. All other Meta arguments can be used in the markup of both operations and services.

The argument can be specified as:

  • atom
  • "string"
  • <<"utf8 binary">>

If the argument is a tuple, as in the case of {ancestor, "[SomeName]"}, {prop, "[name]"} and {prop, "[name]", "[attr]"}, this flexibility only applies to the first element of the tuple. The second and third elements, [SomeName], [name] and [attr], must be strings.

  • owner
    The name of the user in whose configuration tree the mix component resides.
    For example:
    Meta(owner) -> admin@sparkl.com
  • folder
    The folder containing the mix component.
    For example:
    Meta(folder) -> /Scratch/Reinsurance/
    Note: The name of the mix component is excluded from the path.
  • name
    The name of the mix component.
    For example:
    Meta(name) -> MyService
  • path
    The full pathname of the mix component. It is a combination of the arguments:
    For example:
    Meta(path) -> admin@sparkl.com/Scratch/Reinsurance/MyService
  • user
    The name of the user for whom the operation is invoked. It returns the value of undefined if the user is not signed in and thus known to SPARKL.
    Important: The user metadata is only available on operations.
    For example:
    Meta(user) -> user@foo.com
  • {ancestor, "[SomeName]"}
    Depending on the parent folders of the mix component, the function returns the atom true or false.
    It returns true if the mix component that contains the Meta function has any ancestor folder or mix folder with the name [SomeName].
    For example, the following always returns true:
    Meta({ancestor, "Home"}) -> true
  • {prop, "[name]"}
    The text content of the property whose name is [name]. It returns the value of undefined if the property does not exist.
    If the property does not exist on the mix component itself, the function goes up the configuration tree trying to find the closest parent folder which has such a property.
    For example:
    Meta({prop, "expr.src"}) -> ServiceProp = Meta({prop, "expr.src"}), "Ok".
  • {prop, "[name]", "[attr]"}
    The text value of the attribute [attr] on the property whose name is [name]. It returns the value of undefined if either the property or the attribute do not exist.
    If a property with this attribute does not exist on the mix component itself, the function goes up the configuration tree trying to find the closest parent folder which has such a property with the specified attribute.
    For example:
    Meta({prop, "expr.src", "type"}) ->  text/x-erlang