Document::Transform::Role::Transformer - Provides an interface role for Transformers implementations
version 1.110530
package MyTransformer; use Moose; use MooseX::Params::Validate; use MooseX::Types::Moose(':all'); use MyTypeLib(':all'); sub document_constraint { return Document; } sub transform_constraint { return Transform; } sub transform { my $self = shift; my ($doc, $transforms) = validated_list ( \@_, {isa => $self->document_constraint}, {isa => ArrayRef[$self->transform_constraint]}, ); #Do transforms here and return document } with 'Document::Transform::Role::Transformer'; 1;
Want to implement your own transformer and feed it directly to Document::Transform? Then this is your role.
Simply implement a suitable transform method along with the constraint methods or attributes and consume the role.
This role requires that you provide the transform method. If merely substituting your own Transformer implementation, transform will need to take two arguments, a Document structure and an arrayref of Transform structures with the expectation that the operations contained with in each Transform are executed against the Document, and the result returned. The type constraints for Document and Transform are provided in the "document_constraint" and "transform_constrant" attributes or methods
In order to constrain the Document appropriately, this attribute or method must be implemented and must return a Moose::Meta::TypeConstraint.
In order to constrain the Transform appropriately, this attribute or method must be implemented and must return a Moose::Meta::TypeConstraint.
Nicholas R. Perez <nperez@cpan.org>
This software is copyright (c) 2010 by Infinity Interactive.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Document::Transform, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Document::Transform
CPAN shell
perl -MCPAN -e shell install Document::Transform
For more information on module installation, please visit the detailed CPAN module installation guide.