]> git.donarmstrong.com Git - debbugs.git/commitdiff
make constructorargs lazy
authorDon Armstrong <don@donarmstrong.com>
Fri, 8 Jun 2018 20:34:04 +0000 (13:34 -0700)
committerDon Armstrong <don@donarmstrong.com>
Fri, 8 Jun 2018 20:34:12 +0000 (13:34 -0700)
Debbugs/Collection.pm

index c1faa6f6804c745d02649072d9e94b520ccc26d5..cbfd56b31eb8dbb283fdcefbabe1f5372c8e8e1a 100644 (file)
@@ -22,6 +22,7 @@ Debbugs::Collection -- Collection base class which can generate lots of objects
 use Mouse;
 use strictures 2;
 use namespace::autoclean;
+use List::AllUtils qw(pairmap);
 
 extends 'Debbugs::OOBase';
 
@@ -161,9 +162,14 @@ sub get_or_create {
 
 has 'constructor_args' => (is => 'rw',
                           isa => 'ArrayRef',
-                          default => sub {[]},
+                          lazy => 1,
+                           builder => '_build_constructor_args',
                          );
 
+sub _build_constructor_args {
+    return [];
+}
+
 sub add_by_key {
     my $self = shift;
     # we'll assume that add does the right thing. around this in subclasses