From: Ken-ichi Mito Date: Sat, 17 Aug 2013 19:02:01 +0000 (+0900) Subject: remove __super and give closure for $self->directory X-Git-Url: http://lab.mitty.jp/git/?a=commitdiff_plain;h=b8d7413d5c8b859df4d7c7f52349b9112b4acc33;p=lab.git remove __super and give closure for $self->directory --- diff --git a/Dev/github/GitHubBackup.pm b/Dev/github/GitHubBackup.pm index b153d9b..dc147d4 100644 --- a/Dev/github/GitHubBackup.pm +++ b/Dev/github/GitHubBackup.pm @@ -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";