branches/context_object: reformatted with 2-space indent, and "if ("
[p5sagit/Devel-Declare.git] / lib / Devel / Declare / MethodInstaller / Simple.pm
index 0df21d1..4167116 100644 (file)
@@ -8,54 +8,53 @@ use strict;
 use warnings;
 
 sub install_methodhandler {
-    my $class = shift;
-    my %args  = @_;
-    {
-        no strict 'refs';
-        *{$args{into}.'::'.$args{name}}   = sub (&) {};
-    }
-
-    my $ctx = $class->new( %args );
-    Devel::Declare->setup_for(
-        $args{into},
-        { $args{name} => { const => sub { $ctx->parser(@_) } } }
-    );
-
+  my $class = shift;
+  my %args  = @_;
+  {
+    no strict 'refs';
+    *{$args{into}.'::'.$args{name}}   = sub (&) {};
+  }
+
+  my $ctx = $class->new(%args);
+  Devel::Declare->setup_for(
+    $args{into},
+    { $args{name} => { const => sub { $ctx->parser(@_) } } }
+  );
 }
 
 sub parser {
-    my $ctx = shift;
-    $ctx->init(@_);
-
-    $ctx->skip_declarator;
-    my $name   = $ctx->strip_name;
-    my $proto  = $ctx->strip_proto;
-    my @decl   = $ctx->parse_proto($proto);
-    my $inject = $ctx->inject_parsed_proto(@decl);
-    if( defined $name ) {
-        $inject = $ctx->scope_injector_call() . $inject;
-    }
-    $ctx->inject_if_block($inject);
-    if( defined $name ) {
-        my $pkg = $ctx->get_curstash_name;
-        $name = join( '::', $pkg, $name )
-            unless( $name =~ /::/ );
-        $ctx->shadow( sub (&) {
-            my $code = shift;
-            # So caller() gets the subroutine name
-            no strict 'refs';
-            *{$name} = subname $name => $code;
-        });
-    } else {
-        $ctx->shadow(sub (&) { shift });
-    }
+  my $self = shift;
+  $self->init(@_);
+
+  $self->skip_declarator;
+  my $name   = $self->strip_name;
+  my $proto  = $self->strip_proto;
+  my @decl   = $self->parse_proto($proto);
+  my $inject = $self->inject_parsed_proto(@decl);
+  if (defined $name) {
+    $inject = $self->scope_injector_call() . $inject;
+  }
+  $self->inject_if_block($inject);
+  if (defined $name) {
+    my $pkg = $self->get_curstash_name;
+    $name = join( '::', $pkg, $name )
+      unless( $name =~ /::/ );
+    $self->shadow( sub (&) {
+      my $code = shift;
+      # So caller() gets the subroutine name
+      no strict 'refs';
+      *{$name} = subname $name => $code;
+    });
+  } else {
+    $self->shadow(sub (&) { shift });
+  }
 }
+
 sub parse_proto { }
+
 sub inject_parsed_proto {
-    my $ctx = shift;
-    shift;
+  return $_[1];
 }
 
-
 1;