From d0c1ef65d64874c1ad9d9099eaf1c20f389f6441 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 9 Sep 2018 10:45:59 +0200 Subject: Simplify BorgRestore constructors Signed-off-by: Florian Pritz --- lib/App/BorgRestore.pm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index a8d3d5d..d90afe2 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -90,16 +90,13 @@ L =cut method new($class: $deps = {}) { - my $self = {}; - bless $self, $class; - my $db_path = App::BorgRestore::Settings::get_db_path(); my $cache_size = $App::BorgRestore::Settings::sqlite_cache_size; - $self->{deps}->{borg} = $deps->{borg} // App::BorgRestore::Borg->new($App::BorgRestore::Settings::borg_repo); - $self->{deps}->{db} = $deps->{db} // App::BorgRestore::DB->new($db_path, $cache_size); + $deps->{borg} //= App::BorgRestore::Borg->new($App::BorgRestore::Settings::borg_repo); + $deps->{db} //= App::BorgRestore::DB->new($db_path, $cache_size); - return $self; + return $class->new_no_defaults($deps); } =head3 new_no_defaults @@ -113,8 +110,7 @@ method new_no_defaults($class: $deps) { my $self = {}; bless $self, $class; - $self->{deps}->{borg} = $deps->{borg}; - $self->{deps}->{db} = $deps->{db}; + $self->{deps} = $deps; return $self; } -- cgit v1.2.3-24-g4f1b