Mouse::Meta::Class->initialize(scalar caller)->add_override_method_modifier(@_);
}
-sub inner { not_supported }
-sub augment{ not_supported }
+our %INNER_BODY;
+our %INNER_ARGS;
+
+sub inner {
+ my $pkg = caller();
+ if ( my $body = $INNER_BODY{$pkg} ) {
+ my $args = $INNER_ARGS{$pkg};
+ local $INNER_ARGS{$pkg};
+ local $INNER_BODY{$pkg};
+ return $body->(@{$args});
+ }
+ else {
+ return;
+ }
+}
+
+sub augment {
+ #my($name, $method) = @_;
+ Mouse::Meta::Class->initialize(scalar caller)->add_augment_method_modifier(@_);
+}
sub init_meta {
shift;
=cut
+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
\ No newline at end of file
sub add_override_method_modifier {
my ($self, $name, $code) = @_;
- if($self->has_method($name)){\r
- $self->throw_error("Cannot add an override method if a local method is already present");\r
+ if($self->has_method($name)){
+ $self->throw_error("Cannot add an override method if a local method is already present");
}
my $package = $self->name;
return;
}
+sub add_augment_method_modifier {
+ my ($self, $name, $code) = @_;
+ if($self->has_method($name)){
+ $self->throw_error("Cannot add an augment method if a local method is already present");
+ }
+
+ my $super = $self->find_method_by_name($name)
+ or $self->throw_error("You cannot augment '$name' because it has no super method");
+
+ my $super_package = $super->package_name;
+ my $super_body = $super->body;
+
+ $self->add_method($name => sub{
+ local $Mouse::INNER_BODY{$super_package} = $code;
+ local $Mouse::INNER_ARGS{$super_package} = [@_];
+ $super_body->(@_);
+ });
+ return;
+}
+
sub does_role {
my ($self, $role_name) = @_;