[Module-build-checkins] Module-Build/lib/Module/Build Cookbook.pm,1.21,1.22
Status: Beta
Brought to you by:
kwilliams
From: Ken W. <kwi...@us...> - 2006-03-07 04:01:06
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27492/lib/Module/Build Modified Files: Cookbook.pm Log Message: Add subclassing recipe Index: Cookbook.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Cookbook.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Cookbook.pm 4 Mar 2006 00:42:45 -0000 1.21 +++ Cookbook.pm 7 Mar 2006 04:00:53 -0000 1.22 @@ -329,6 +329,40 @@ =back 4 +=head2 Modifying an action + +Sometimes you might need an to have an action, say C<./Build install>, +do something unusual. For instance, you might need to change the +ownership of a file or do something else peculiar to your application. + +You can subclass C<Module::Build> on the fly using the C<subclass()> +method and override the methods that perform the actions. You may need +to read through C<Module::Build::Authoring> to find the methods you +want to override, but the general pattern is C<ACTION_> followed by +the name of the action you want to modify. Here's an example of how +it would work for C<install>: + + # Build.PL + use Module::Build; + my $class = Module::Build->subclass( + class => "Module::Build::Custom", + code => <<'SUBCLASS' ); + + sub ACTION_install { + my $self = shift; + # YOUR CODE HERE + $self->SUPER::ACTION_install; + } + SUBCLASS + + $class->new( + module_name => 'Your::Module', + # rest of the usual Module::Build parameters + )->create_build_script; + +See the C<Module::Build::Authoring> pod in 0.27 or above for more +complete documentation on this. + =head1 AUTHOR Ken Williams <ke...@cp...> |