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