1 package Moose::Meta::Method::Augmented;
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
10 use base 'Moose::Meta::Method';
13 my ( $class, %args ) = @_;
15 # the package can be overridden by roles
16 # it is really more like body's compilation stash
17 # this is where we need to override the definition of super() so that the
18 # body of the code can call the right overridden version
19 my $name = $args{name};
20 my $meta = $args{class};
22 my $super = $meta->find_next_method_by_name($name);
25 || $meta->throw_error("You cannot augment '$name' because it has no super method", data => $name);
27 my $_super_package = $super->package_name;
28 # BUT!,... if this is an overridden method ....
29 if ($super->isa('Moose::Meta::Method::Overridden')) {
30 # we need to be sure that we actually
31 # find the next method, which is not
32 # an 'override' method, the reason is
33 # that an 'override' method will not
34 # be the one calling inner()
35 my $real_super = $meta->_find_next_method_by_name_which_is_not_overridden($name);
36 $_super_package = $real_super->package_name;
39 my $super_body = $super->body;
41 my $method = $args{method};
44 local $Moose::INNER_ARGS{$_super_package} = [ @_ ];
45 local $Moose::INNER_BODY{$_super_package} = $method;
49 # FIXME store additional attrs
52 package_name => $meta->name,
65 Moose::Meta::Method::Augmented - A Moose Method metaclass for augmented methods
69 This class implements method augmenting logic for the L<Moose> C<augment> keyword.
71 This involves setting up C<inner> for the superclass body, and dispatching to
72 the superclass from the normal body.
74 The subclass definition (the augmentation itself) will be invoked explicitly
75 using the C<inner> keyword from the parent class's method definition.
87 All complex software has bugs lurking in it, and this module is no
88 exception. If you find a bug please either email me, or add the bug
93 Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
95 =head1 COPYRIGHT AND LICENSE
97 Copyright 2006-2009 by Infinity Interactive, Inc.
99 L<http://www.iinteractive.com>
101 This library is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself.