Skip Menu |
 

This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id: 45172
Status: resolved
Priority: 0/
Queue: Module-Build

People
Owner: Nobody in particular
Requestors: bdfoy [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.32_01
Fixed in: (no value)



Subject: Add can_action to check for defined actions
Download (untitled) / with headers
text/plain 1.8k
I'm creating a subclass of Module::Build for some automating testing. Parts of this testing involves special ./Build targets depending on certain situations and my build script checks for certain targets. I wanted a method to check it a target is defined and figured it should be in Base.pm. I want to shield the higher-level users from knowing about the implementation details of Module::Build so they don't have to know the real method name as long as they know the action name. I added a method called can_action, but it could be called something else. Index: lib/Module/Build/Base.pm =================================================================== --- lib/Module/Build/Base.pm (revision 12711) +++ lib/Module/Build/Base.pm (working copy) @@ -1585,11 +1585,17 @@ return if $self->{_completed_actions}{$action}++; local $self->{action} = $action; - my $method = "ACTION_$action"; - die "No action '$action' defined, try running the 'help' action.\n" unless $self->can($method); + my $method = $self->can_action( $action ); + die "No action '$action' defined, try running the 'help' action.\n" unless $method; return $self->$method(); } +sub can_action { + my ($self, $action) = @_; + + return $self->can( "ACTION_$action" ); +} + # cuts the user-specified options out of the command-line args sub cull_options { my $self = shift; Index: lib/Module/Build/API.pod =================================================================== --- lib/Module/Build/API.pod (revision 12711) +++ lib/Module/Build/API.pod (working copy) @@ -959,6 +959,13 @@ Returns a hash reference indicating the C<build_requires> prerequisites that were passed to the C<new()> method. +=item can_action( $action ) + +Returns a reference to the method that defines C<$action>, or false +otherwise. This is handy for actions defined (or maybe not!) in subclasses. + +[version 0.32_xx] + =item cbuilder() [version 0.2809]
I like it. Any objections from the other maintainers? -Ken
Subject: Re: [rt.cpan.org #45172] Add can_action to check for defined actions
Date: Mon, 20 Apr 2009 22:20:52 -0400
To: bug-Module-Build [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
Download (untitled) / with headers
text/plain 286b
Looks great to me. On Mon, Apr 20, 2009 at 10:01 PM, Ken Williams via RT <bug-Module-Build@rt.cpan.org> wrote: Show quoted text
>       Queue: Module-Build >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=45172 > > > I like it.  Any objections from the other maintainers? > >  -Ken > >
+1
Patch applied, finally. -Ken


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.