Barry King > Apache-Wyrd > Apache::Wyrd::Interfaces::Mother

Download:
Apache-Wyrd-0.98.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.98   Source  

NAME ^

Apache::Wyrd::Interfaces::Mother - Reverse-parsing interface for Wyrds

SYNOPSIS ^

NONE

DESCRIPTION ^

If the enclosing Wyrd is the parent of an enclosed wyrd, the Mother interface allows "children" of a Wyrd to be processed AFTER the parent, reversing the normal flow of interpretation and calling the output method.

This is used, for example, in Forms, where the Apache::Wyrd::Form will need to alter values in the enclosed Apache::Wyrd::Inputs and similar children after they have been parsed.

To accomplish this, every child must call the register_child method. This will give the mother a private attribute _children containing an arrayref to the child objects.

When the mother has manipulated its children via access to the _children arrayref, it calls _set_children to output the children to their place within the enclosed HTML. For this to function, each child must have a final_output method to call, and must output '$:'+ the id returned by the _register_child method. Typically this is done with the following code:

    $self->_data('$:' . $id);

METHODS ^

(format: (returns) name (accepts))

(void) _set_children ([string])

Prior to producing output, the mother should, assuming _data contains the enclosed data at the time, call _set_children to perform the delayed processing of its children. Set children operates on the _data attribute, so be sure the children's placemarkers are in _data before calling this method.

When used with the optional argument, that attribute is assumed to be the storage place for the children rather than _data.

(scalar) register_child (void)

Adds the child to the mother's _children attribute and returns a placemarker string the mother will use to find it. Every child of the mother should call register_child. In so doing, it should set it's output (usually during the _generate_output phase) with the string "$:idname" where idname is the id returned by this method. It can do this in any way it likes, for example by replacing it's _data attribute, as long as it's output method returns this value.

(scalar) _process_child (Apache::Wyrd-derived object)

Hook method for performing some action on or using each child.

BUGS/CAVEATS/RESERVED METHODS ^

The methods _name_child, _generate_id, _set_children, and _child_hash are reserved by this interface.

Children must ensure that the '$:' string before the ID string is not interpreted by perl as the $: variable, i.e. use single quotes/q() around the string. See Apache::Wyrd::Interfaces::Setter.

AUTHOR ^

Barry King <wyrd@nospam.wyrdwright.com>

SEE ALSO ^

Apache::Wyrd

General-purpose HTML-embeddable perl object

LICENSE ^

Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.

See LICENSE under the documentation for Apache::Wyrd.

syntax highlighting: