From b8d7413d5c8b859df4d7c7f52349b9112b4acc33 Mon Sep 17 00:00:00 2001 From: Ken-ichi Mito Date: Sun, 18 Aug 2013 04:02:01 +0900 Subject: [PATCH] remove __super and give closure for $self->directory --- Dev/github/GitHubBackup.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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"; -- 1.7.9.5