1 package Moose::Meta::Method::Overridden;
6 our $AUTHORITY = 'cpan:STEVAN';
8 use base 'Moose::Meta::Method';
11 my ( $class, %args ) = @_;
13 # the package can be overridden by roles
14 # it is really more like body's compilation stash
15 # this is where we need to override the definition of super() so that the
16 # body of the code can call the right overridden version
17 my $super_package = $args{package} || $args{class}->name;
19 my $name = $args{name};
21 my $super = $args{class}->find_next_method_by_name($name);
24 || $class->throw_error("You cannot override '$name' because it has no super method", data => $name);
26 my $super_body = $super->body;
28 my $method = $args{method};
31 local $Moose::SUPER_PACKAGE = $super_package;
32 local @Moose::SUPER_ARGS = @_;
33 local $Moose::SUPER_BODY = $super_body;
37 # FIXME do we need this make sure this works for next::method?
38 # subname "${super_package}::${name}", $method;
40 # FIXME store additional attrs
43 package_name => $args{class}->name,
50 # ABSTRACT: A Moose Method metaclass for overridden methods
58 This class implements method overriding logic for the L<Moose>
61 The overriding subroutine's parent will be invoked explicitly using
62 the C<super> keyword from the parent class's method definition.
68 =item B<< Moose::Meta::Method::Overridden->new(%options) >>
70 This constructs a new object. It accepts the following options:
76 The metaclass object for the class in which the override is being
77 declared. This option is required.
81 The name of the method which we are overriding. This method must exist
82 in one of the class's superclasses. This option is required.
86 The subroutine reference which implements the overriding. This option
95 See L<Moose/BUGS> for details on reporting bugs.