Mock::Data::GeneratorSub - Wrap a coderef to become a blessed Generator object
This class wraps a generator coderef to become a Generator object, and supply default parameters for "generate" which can be overridden or combined with additional parameters.
Mock::Data::GeneratorSub->new( $coderef, @default_params );
This object's generate method calls the $coderef after merging the parameters passed to generate with this list of @default_params. When merging parameters, named parameters are replaced by-name, and positional parameters are replacing entirely if new positional parameters are provided.
generate
$coderef
@default_params
$generator->generate($mock, @params);
Merge @params with $self->params and then call $self->coderef
@params
$self->params
$self->coderef
$generator->compile(@params);
Return a function sub($mock){ ... } which calls $self->coderef with the @params merged with $self->params.
sub($mock){ ... }
Michael Conrad <mike@nrdvana.net>
version 0.01
This software is copyright (c) 2021 by Michael Conrad.
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 Mock::Data, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mock::Data
CPAN shell
perl -MCPAN -e shell install Mock::Data
For more information on module installation, please visit the detailed CPAN module installation guide.