The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DS::Transformer - receives, transforms and passes on rows

DESCRIPTION

This class is the base class of all transformers in DS. If you need to write a transformer, first consider if DS::Transformer::Sub will do. It supports any kind of row-wise transformations where there is a one-to-one correspondence between incoming and outgoing rows.

SUPER CLASSES

DS::Transformer is a mixin of DS::Source and DS::Target.

METHODS

process( $row )

Method for processing of ingoing data. This method is supposed to be overridden. By default it will return $row.

new( $class, $in_type, $out_type, $source, $target )

Constructor. Instantiates an object of class $class, taking the type $in_type, returning the type $out_type, attached to the source $source and attaced to the target $target. Besides $class, any of the parameters can be left out.

attach_target( $target )

Attaches target $target to this object. This method also triggers type checking, ensuring that the outgoing type of this object is sufficient for $target. If the type check fails, an exception is thrown.

target( $target )

This is a method mostly for internal use. It will get or set the target, bypassing type checks.

pass_row( $row )

Calling this metod will cause the transformer to pass $row to the target $target.

out_type( $type )

This is an accessor that gets or sets the outgoing type of this object.

receive_row( $row )

Triggers processing of $row. This method calls process with $row, and then passes the result to pass_row.

attach_source( $source )

Attaches $source as source. This method also validates data types by calling validate_source_type, throwing an exception if the validation fails.

source( $source )

Accessor for source. This method sets the source of this object and triggers type checking.

validate_source_type( $source_type )

Validates source type. If the $source_type is not valid, it returns false, true otherwise. By default, this method ensures that the ingoing type of this object contains no fields not specified in $source_type. Override if you need more complex checking.

in_type( $type )

Accessor for ingoing type.

SEE ALSO

DS::Transformer::Sub, DS::Source, DS::Target.

AUTHOR

Written by Michael Zedeler.