1 package Moose::Meta::Method::Overridden;
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 $super_package = $args{package} || $args{class}->name;
21 my $name = $args{name};
23 my $super = $args{class}->find_next_method_by_name($name);
26 || $class->throw_error("You cannot override '$name' because it has no super method", data => $name);
28 my $super_body = $super->body;
30 my $method = $args{method};
33 local $Moose::SUPER_PACKAGE = $super_package;
34 local @Moose::SUPER_ARGS = @_;
35 local $Moose::SUPER_BODY = $super_body;
39 # FIXME do we need this make sure this works for next::method?
40 # subname "${super_package}::${name}", $method;
42 # FIXME store additional attrs
45 package_name => $args{class}->name,
58 Moose::Meta::Method::Overridden - A Moose Method metaclass for overridden methods
62 This class implements method overriding logic for the L<Moose>
65 The overriding subroutine's parent will be invoked explicitly using
66 the C<super> keyword from the parent class's method definition.
72 =item B<< Moose::Meta::Method::Overridden->new(%options) >>
74 This constructs a new object. It accepts the following options:
80 The metaclass object for the class in which the override is being
81 declared. This option is required.
85 The name of the method which we are overriding. This method must exist
86 in one of the class's superclasses. This option is required.
90 The subroutine reference which implements the overriding. This option
99 All complex software has bugs lurking in it, and this module is no
100 exception. If you find a bug please either email me, or add the bug
105 Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
107 =head1 COPYRIGHT AND LICENSE
109 Copyright 2006-2009 by Infinity Interactive, Inc.
111 L<http://www.iinteractive.com>
113 This library is free software; you can redistribute it and/or modify
114 it under the same terms as Perl itself.