[Bps-public-commit] r12528 - in Prophet/branches/moose: .

sartak at bestpractical.com sartak at bestpractical.com
Mon May 19 09:27:05 EDT 2008


Author: sartak
Date: Mon May 19 09:27:04 2008
New Revision: 12528

Modified:
   Prophet/branches/moose/   (props changed)
   Prophet/branches/moose/lib/Prophet/Replica/Native.pm

Log:
 r56340 at onn:  sartak | 2008-05-19 09:26:44 -0400
 Move some logic out of BUILD and into the attributes


Modified: Prophet/branches/moose/lib/Prophet/Replica/Native.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/Replica/Native.pm	(original)
+++ Prophet/branches/moose/lib/Prophet/Replica/Native.pm	Mon May 19 09:27:04 2008
@@ -20,11 +20,21 @@
 );
 
 has fs_root_parent => (
-    is => 'rw',
+    is      => 'rw',
+    lazy    => 1,
+    default => sub {
+        my $self = shift;
+        $self->fs_root_parent($self->url =~ m{^file://(.*)/.*?$});
+    },
 );
 
 has fs_root => (
-    is => 'rw',
+    is      => 'rw',
+    lazy    => 1,
+    default => sub {
+        my $self = shift;
+        $self->fs_root($self->url =~ m{^file://(.*)$});
+    },
 );
 
 has target_replica => (
@@ -35,6 +45,31 @@
     is => 'rw',
 );
 
+has '+resolution_db_handle' => (
+    isa     => 'Prophet::Replica | Undef',
+    lazy    => 1,
+    default => sub {
+        my $self = shift;
+        return if $self->is_resdb || $self->is_state_handle;
+        return Prophet::Replica->new({
+            url      => "prophet:" . $self->url . '/resolutions',
+            is_resdb => 1,
+        })
+    },
+);
+
+#has '+state_handle' => (
+#    isa     => 'Prophet::Replica | Undef',
+#    lazy    => 1,
+#    default => sub {
+#        return if $self->is_state_handle;
+#        return Prophet::Replica->new({
+#            url             => "prophet:" . $self->url,
+#            is_state_handle => 1
+#        });
+#    },
+#);
+
 use constant scheme            => 'prophet';
 use constant cas_root          => 'cas';
 use constant record_cas_dir    => dir( __PACKAGE__->cas_root => 'records' );
@@ -53,19 +88,8 @@
     $self->{url}
         =~ s/^prophet://;  # url-based constructor in ::replica should do better
     $self->{url} =~ s{/$}{};
-    $self->fs_root( $self->url        =~ m{^file://(.*)$} );
-    $self->fs_root_parent( $self->url =~ m{^file://(.*)/.*?$} );
     $self->_probe_or_create_db();
 
-# $self->state_handle( Prophet::Replica->new( { url => "prophet:".$self->{url}, is_state_handle =>1 } ) ) unless ( $self->is_state_handle || $self->state_handle);
-
-    $self->resolution_db_handle(
-        Prophet::Replica->new(
-            {   url      => "prophet:" . $self->{url} . '/resolutions',
-                is_resdb => 1
-            }
-        )
-    ) unless ( $self->is_resdb || $self->is_state_handle );
 
     #    warn "I AM ".$ENV{'PROPHET_USER'};
     #    warn $self->uuid;



More information about the Bps-public-commit mailing list