remove __super and give closure for $self->directory
authorKen-ichi Mito <mitty@mitty.jp>
Sat, 17 Aug 2013 19:02:01 +0000 (04:02 +0900)
committerKen-ichi Mito <mitty@mitty.jp>
Sat, 17 Aug 2013 19:02:01 +0000 (04:02 +0900)
Dev/github/GitHubBackup.pm

index b153d9b..dc147d4 100644 (file)
@@ -57,7 +57,7 @@ sub repos {
     if (my $repository = $self->repository) {
         $self->{repos} = [
             GitHubBackup::Repository->new({
-                __super   => $self,
+                directory => sub {$self->directory},
                 full_name => "$account/$repository",
             })
         ];
@@ -81,7 +81,7 @@ sub repos {
     foreach my $repos (@repos) {
         push @{$self->{repos}},
             GitHubBackup::Repository->new({
-                __super   => $self,
+                directory => sub {$self->directory},
                 full_name => $repos->{full_name},
                 clone_url => $repos->{clone_url},
             })
@@ -102,6 +102,7 @@ use Carp qw(croak);
 use Git::Repository;
 use File::chdir;
 
+
 sub new {
     my $class = shift;
     my $args  = shift;
@@ -114,10 +115,16 @@ sub new {
     return $class->SUPER::new($args);
 }
 
+sub directory {
+    my $self = shift;
+    
+    return $self->{directory}->();
+}
+
 sub clone_git {
     my $self = shift;
     
-    my $dir = $self->{__super}->directory .'/'. $self->{full_name};
+    my $dir = $self->directory .'/'. $self->{full_name};
     if (-d "$dir") {
         local $CWD = $dir;
         print "fetch ", $self->{full_name}, "\n";