[Catalyst-commits] r9938 - Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter

rafl at dev.catalyst.perl.org rafl at dev.catalyst.perl.org
Wed Apr 29 13:34:23 GMT 2009


Author: rafl
Date: 2009-04-29 14:34:23 +0100 (Wed, 29 Apr 2009)
New Revision: 9938

Modified:
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm
Log:
Convert the restarter engine's BUILD method to lazy attribute builders.

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm	2009-04-29 10:45:34 UTC (rev 9937)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter/Watcher.pm	2009-04-29 13:34:23 UTC (rev 9938)
@@ -22,26 +22,21 @@
 
 has delay => (is => 'rw');
 has regex => (is => 'rw');
-has modified => (is => 'rw');
+has modified => (is => 'rw', builder => '_build_modified', lazy => 1);
 has directory => (is => 'rw');
-has watch_list => (is => 'rw');
+has watch_list => (is => 'rw', builder => '_build_watch_list', lazy => 1);
 has follow_symlinks => (is => 'rw');
 
-sub BUILD {
-    shift->_init;
+sub _build_watch_list {
+    my ($self) = @_;
+    return $self->_index_directory;
 }
 
-sub _init {
-    my $self = shift;
-
-    my $watch_list = $self->_index_directory;
-    $self->watch_list($watch_list);
-
-    $self->modified(
-        File::Modified->new(
-            method => 'mtime',
-            files  => [ keys %{$watch_list} ],
-        )
+sub _build_modified {
+    my ($self) = @_;
+    return File::Modified->new(
+        method => 'mtime',
+        files  => [ keys %{ $self->watch_list } ],
     );
 }
 




More information about the Catalyst-commits mailing list