CPANPLUS::Dist::Gentoo::Guard - Scope guard object.


CPANPLUS-Dist-Gentoo documentation Contained in the CPANPLUS-Dist-Gentoo distribution.

Index


Code Index:

NAME

Top

CPANPLUS::Dist::Gentoo::Guard - Scope guard object.

VERSION

Top

Version 0.11

DESCRIPTION

Top

This is a scope guard object helper for CPANPLUS::Dist::Gentoo.

METHODS

Top

new $coderef

Creates a new CPANPLUS::Dist::Gentoo::Guard object that will call $coderef when destroyed.

unarm

Tells the object not to call the stored callback on destruction.

DESTROY

Calls the stored callback if the guard object is still armed.

SEE ALSO

Top

CPANPLUS::Dist::Gentoo.

AUTHOR

Top

Vincent Pit, <perl at profvince.com>, http://www.profvince.com.

You can contact me by mail or on irc.perl.org (vincent).

BUGS

Top

Please report any bugs or feature requests to bug-cpanplus-dist-gentoo at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPANPLUS-Dist-Gentoo. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc CPANPLUS::Dist::Gentoo

COPYRIGHT & LICENSE

Top


CPANPLUS-Dist-Gentoo documentation Contained in the CPANPLUS-Dist-Gentoo distribution.
package CPANPLUS::Dist::Gentoo::Guard;

use strict;
use warnings;

our $VERSION = '0.11';

sub new {
 my ($class, $code) = @_;
 $class = ref($class) || $class;

 bless {
  code  => $code,
  armed => 1,
 }, $class;
}

sub unarm { $_[0]->{armed} = 0 }

sub DESTROY {
 my ($self) = @_;

 $self->{code}->() if $self->{armed};
 $self->unarm;

 return;
}

1; # End of CPANPLUS::Dist::Gentoo::Guard