1 package Moose::Meta::Method::Augmented;
6 our $AUTHORITY = 'cpan:STEVAN';
8 use base 'Moose::Meta::Method';
11 my ( $class, %args ) = @_;
13 # the package can be overridden by roles
14 # it is really more like body's compilation stash
15 # this is where we need to override the definition of super() so that the
16 # body of the code can call the right overridden version
17 my $name = $args{name};
18 my $meta = $args{class};
20 my $super = $meta->find_next_method_by_name($name);
23 || $meta->throw_error("You cannot augment '$name' because it has no super method", data => $name);
25 my $_super_package = $super->package_name;
26 # BUT!,... if this is an overridden method ....
27 if ($super->isa('Moose::Meta::Method::Overridden')) {
28 # we need to be sure that we actually
29 # find the next method, which is not
30 # an 'override' method, the reason is
31 # that an 'override' method will not
32 # be the one calling inner()
33 my $real_super = $meta->_find_next_method_by_name_which_is_not_overridden($name);
34 $_super_package = $real_super->package_name;
37 my $super_body = $super->body;
39 my $method = $args{method};
42 local $Moose::INNER_ARGS{$_super_package} = [ @_ ];
43 local $Moose::INNER_BODY{$_super_package} = $method;
47 # FIXME store additional attrs
50 package_name => $meta->name,
57 # ABSTRACT: A Moose Method metaclass for augmented methods
65 This class implements method augmentation logic for the L<Moose>
68 The augmentation subroutine reference will be invoked explicitly using
69 the C<inner> keyword from the parent class's method definition.
73 C<Moose::Meta::Method::Augmented> is a subclass of L<Moose::Meta::Method>.
79 =item B<< Moose::Meta::Method::Augmented->new(%options) >>
81 This constructs a new object. It accepts the following options:
87 The metaclass object for the class in which the augmentation is being
88 declared. This option is required.
92 The name of the method which we are augmenting. This method must exist
93 in one of the class's superclasses. This option is required.
97 The subroutine reference which implements the augmentation. This
106 See L<Moose/BUGS> for details on reporting bugs.