NAME

Schedule::Activity::Message - Container for individual or multiple messages

SYNOPSIS

my $message=Schedule::Activity::Message->new(
  message   =>'key name',
  message   =>'string message', attributes=>{...},
  message   =>['array', 'of', 'alternates'],
  message   =>{name=>key},
  message   =>{
    alternates=>[
      {message=>'string', attributes=>{...}},
      {name=>key},
      ...
    ],
  },
  names=>{
    key=>{string, array, or hash configuration},
  },
  note      =>...   # optional
);

DESCRIPTION

A message object permits storage and generation of one or more associated string messages. A simple string always returns the string as the message, but arrays of alternates permit random selection of messages. Messages may also be referenced by a common structure of named messages, shared across message objects.

Both hash-alternate and named messages permit association of attributes, possibly different for each alternate.

CONFIGURATION

message=>'A message string'
message=>'named message key'
message=>['An array','of alternates','chosen randomly']
message=>{name=>'named message key'}
message=>{
  alternates=>[
    {message=>'A hash containing an array', attributes=>{...}}
    {message=>'of alternates',              attributes=>{...}}
    {message=>'with optional attributes',   attributes=>{...}}
    {message=>'named message key'}
    {name=>'named message key'}
  ]
}

Message selection is randomized for arrays and a hash of alternates. Named messages must exist. If a simple message string matches a named message key, the name takes precedence.

Named messages may only create string, array, or hash messages. They cannot reference another name.

FUNCTIONS

A Message object provides the following functions.

random

Retrieve a pair of (message,object), which is either an individual string message, or a random selection from an array or hash of alternatives. The first index will always be a string, possibly empty. The object can be used to inspect message attributes.

attributesFromConf

Given a plain (unknown) message configuration, find any embedded attributes. This function is primarily useful during schedule configuration validation, prior to full action nodes being built, to identify all attributes within a nested configuration. It does not need to handle named attributes because those are separately declared.

BUGS

As of version 0.1.2, there is very little validation of the names contents.