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