Aspect::Pointcut::True - Pointcut that allows arbitrary Perl code


Aspect documentation Contained in the Aspect distribution.

Index


Code Index:

NAME

Top

Aspect::Pointcut::True - Pointcut that allows arbitrary Perl code

SYNOPSIS

Top

  use Aspect;

  # High-level creation
  my $pointcut1 = true { rand() > 0.5 };

  # Manual creation
  my $pointcut2 = Aspect::Pointcut::True->new(
    sub { rand() > 0.5 }
  );

DESCRIPTION

Top

Because Aspect's weaving phase technically occurs at run-time (relative to the overall process) it does not need to be limit itself only to conditions that are fully describable at compile-time.

Aspect::Pointcut::True allows you to take advantage of this to create your own custom run-time pointcut conditions, although for safety and purity reasons you are not permitted to create custom conditions that interact with the Aspect::Point object for the call.

AUTHORS

Top

Adam Kennedy <adamk@cpan.org>

Marcel Grünauer <marcel@cpan.org>

Ran Eilam <eilara@cpan.org>

COPYRIGHT

Top


Aspect documentation Contained in the Aspect distribution.

package Aspect::Pointcut::True;

use strict;
use warnings;
use Aspect::Pointcut ();

our $VERSION = '1.01';
our @ISA     = 'Aspect::Pointcut';





######################################################################
# Weaving Methods

# The true pointcut is a run-time only pointcut
sub curry_weave {
	return;
}

# The true pointcut contains no state and doesn't need to be curried.
# Simply return it as-is and reuse it everywhere.
sub curry_runtime {
	return $_[0];
}





######################################################################
# Runtime Methods

sub compile_runtime {
	$_[0]->[0];
}





######################################################################
# Optional XS Acceleration

BEGIN {
	local $@;
	eval <<'END_PERL';
use Class::XSAccessor::Array 1.08 {
	replace => 1,
	getters => {
		'compile_runtime' => 0,
	},
};
END_PERL
}

1;

__END__