1 package Devel::Declare::MethodInstaller::Simple;
3 use base 'Devel::Declare::Context::Simple';
10 our $VERSION = '0.006020';
12 sub install_methodhandler {
17 *{$args{into}.'::'.$args{name}} = sub (&) {};
20 my $warnings = warnings::enabled("redefine");
21 my $ctx = $class->new(%args);
22 Devel::Declare->setup_for(
24 { $args{name} => { const => sub { $ctx->parser(@_, $warnings) } } }
29 my ($self, $name) = @_;
32 my $pkg = $self->get_curstash_name;
33 $name = join( '::', $pkg, $name )
34 unless( $name =~ /::/ );
37 # So caller() gets the subroutine name
39 my $installer = $self->warning_on_redefine
40 ? sub { *{$name} = subname $name => $code; }
41 : sub { no warnings 'redefine';
42 *{$name} = subname $name => $code; };
47 return sub (&) { shift };
52 my ($self, $name ) = @_;
54 $self->shadow( $self->code_for($name) );
61 $self->skip_declarator;
62 my $name = $self->strip_name;
63 my $proto = $self->strip_proto;
64 my $attrs = $self->strip_attrs;
65 my @decl = $self->parse_proto($proto);
66 my $inject = $self->inject_parsed_proto(@decl);
68 $inject = $self->scope_injector_call() . $inject;
70 $self->inject_if_block($inject, $attrs ? "sub ${attrs} " : '');
72 $self->install( $name );
77 sub parse_proto { '' }
79 sub inject_parsed_proto {