1 package Moose::Meta::Method::Overridden;
6 use base 'Moose::Meta::Method';
9 my ( $class, %args ) = @_;
11 # the package can be overridden by roles
12 # it is really more like body's compilation stash
13 # this is where we need to override the definition of super() so that the
14 # body of the code can call the right overridden version
15 my $super_package = $args{package} || $args{class}->name;
17 my $name = $args{name};
19 my $super = $args{class}->find_next_method_by_name($name);
22 || $class->throw_error("You cannot override '$name' because it has no super method", data => $name);
24 my $super_body = $super->body;
26 my $method = $args{method};
29 local $Moose::SUPER_PACKAGE = $super_package;
30 local @Moose::SUPER_ARGS = @_;
31 local $Moose::SUPER_BODY = $super_body;
35 # FIXME do we need this make sure this works for next::method?
36 # subname "${super_package}::${name}", $method;
38 # FIXME store additional attrs
41 package_name => $args{class}->name,
48 # ABSTRACT: A Moose Method metaclass for overridden methods
56 This class implements method overriding logic for the L<Moose>
59 The overriding subroutine's parent will be invoked explicitly using
60 the C<super> keyword from the parent class's method definition.
66 =item B<< Moose::Meta::Method::Overridden->new(%options) >>
68 This constructs a new object. It accepts the following options:
74 The metaclass object for the class in which the override is being
75 declared. This option is required.
79 The name of the method which we are overriding. This method must exist
80 in one of the class's superclasses. This option is required.
84 The subroutine reference which implements the overriding. This option
93 See L<Moose/BUGS> for details on reporting bugs.