summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-09-09 10:45:59 +0200
committerFlorian Pritz <bluewind@xinu.at>2018-09-09 15:45:11 +0200
commitd0c1ef65d64874c1ad9d9099eaf1c20f389f6441 (patch)
tree7b301beb3fa57240c1aceec45725150fc83a6f2a
parent8fb0956025803f519c2101c8279da13b77d856b1 (diff)
downloadApp-BorgRestore-d0c1ef65d64874c1ad9d9099eaf1c20f389f6441.tar.gz
App-BorgRestore-d0c1ef65d64874c1ad9d9099eaf1c20f389f6441.tar.xz
Simplify BorgRestore constructors
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--lib/App/BorgRestore.pm12
1 files changed, 4 insertions, 8 deletions
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<App::BorgRestore::DB>
=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;
}