1 package Moose::Meta::Method::Augmented;
6 use base 'Moose::Meta::Method';
9 my ( $class, %args ) = @_;
11 # the package can be overridden by roles
12 # it is really more like body's compilation stash
13 # this is where we need to override the definition of super() so that the
14 # body of the code can call the right overridden version
15 my $name = $args{name};
16 my $meta = $args{class};
18 my $super = $meta->find_next_method_by_name($name);
21 || $meta->throw_error("You cannot augment '$name' because it has no super method", data => $name);
23 my $_super_package = $super->package_name;
24 # BUT!,... if this is an overridden method ....
25 if ($super->isa('Moose::Meta::Method::Overridden')) {
26 # we need to be sure that we actually
27 # find the next method, which is not
28 # an 'override' method, the reason is
29 # that an 'override' method will not
30 # be the one calling inner()
31 my $real_super = $meta->_find_next_method_by_name_which_is_not_overridden($name);
32 $_super_package = $real_super->package_name;
35 my $super_body = $super->body;
37 my $method = $args{method};
40 local $Moose::INNER_ARGS{$_super_package} = [ @_ ];
41 local $Moose::INNER_BODY{$_super_package} = $method;
45 # FIXME store additional attrs
48 package_name => $meta->name,
55 # ABSTRACT: A Moose Method metaclass for augmented methods
63 This class implements method augmentation logic for the L<Moose>
66 The augmentation subroutine reference will be invoked explicitly using
67 the C<inner> keyword from the parent class's method definition.
71 C<Moose::Meta::Method::Augmented> is a subclass of L<Moose::Meta::Method>.
77 =item B<< Moose::Meta::Method::Augmented->new(%options) >>
79 This constructs a new object. It accepts the following options:
85 The metaclass object for the class in which the augmentation is being
86 declared. This option is required.
90 The name of the method which we are augmenting. This method must exist
91 in one of the class's superclasses. This option is required.
95 The subroutine reference which implements the augmentation. This
104 See L<Moose/BUGS> for details on reporting bugs.