use warnings;
use Carp 'confess';
-use Scalar::Util 'reftype', 'blessed';
-use Sub::Name 'subname';
+use Scalar::Util 'blessed';
-our $VERSION = '0.02';
+our $VERSION = '0.63';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Method';
};
sub wrap {
- my $class = shift;
- my $code = shift;
+ my ( $class, $code, %params ) = @_;
+
(blessed($code) && $code->isa('Class::MOP::Method'))
|| confess "Can only wrap blessed CODE";
+
my $modifier_table = {
cache => undef,
orig => $code,
},
};
$_build_wrapped_method->($modifier_table);
- my $method = $class->SUPER::wrap(sub { $modifier_table->{cache}->(@_) });
+ my $method = $class->SUPER::wrap(
+ sub { $modifier_table->{cache}->(@_) },
+ # get these from the original
+ # unless explicitly overriden
+ package_name => $params{package_name} || $code->package_name,
+ name => $params{name} || $code->name,
+ );
$method->{'%!modifier_table'} = $modifier_table;
$method;
}
Class::MOP::Method::Wrapped - Method Meta Object to handle before/around/after modifiers
-=head1 SYNOPSIS
-
- # ... more to come later maybe
-
=head1 DESCRIPTION
+This is a L<Class::MOP::Method> subclass which provides the funtionality
+to wrap a given CODE reference with before, after and around method modifiers.
+
=head1 METHODS
=head2 Construction
=over 4
-=item B<wrap (&code)>
+=item B<wrap ($code)>
+
+This is the constructor, it will return a B<Class::MOP::Method::Wrapped>
+instance that can be used to add before, after and around modifiers to.
=item B<get_original_method>
+This returns the original CODE reference that was provided to the
+constructor.
+
=back
=head2 Modifiers
+These three methods will add the method modifiers to the wrapped
+CODE reference. For more information on how method modifiers work,
+see the section in L<Class::MOP::Class>.
+
=over 4
=item B<add_before_modifier ($code)>