[Bps-public-commit] r16717 - in Prophet/branches/init-and-clone: .

sartak at bestpractical.com sartak at bestpractical.com
Thu Nov 6 12:07:09 EST 2008


Author: sartak
Date: Thu Nov  6 12:07:08 2008
New Revision: 16717

Modified:
   Prophet/branches/init-and-clone/   (props changed)
   Prophet/branches/init-and-clone/lib/Prophet/DatabaseSetting.pm

Log:
 r75128 at onn:  sartak | 2008-11-06 12:06:56 -0500
 tidy, immutable, etc


Modified: Prophet/branches/init-and-clone/lib/Prophet/DatabaseSetting.pm
==============================================================================
--- Prophet/branches/init-and-clone/lib/Prophet/DatabaseSetting.pm	(original)
+++ Prophet/branches/init-and-clone/lib/Prophet/DatabaseSetting.pm	Thu Nov  6 12:07:08 2008
@@ -1,16 +1,17 @@
 package Prophet::DatabaseSetting;
 use Moose;
 extends 'Prophet::Record';
+
 use Params::Validate;
 use JSON;
 
 has default => (
-    is => 'ro'
+    is => 'ro',
 );
 
 has label => (
-    isa => 'Maybe[Str]',
-    is => 'rw' 
+    isa => 'Str',
+    is  => 'rw',
 );
 
 sub BUILDARGS {
@@ -36,23 +37,36 @@
 sub set {
     my $self = shift;
     my $entry;
-    if (exists $_[1]  || !ref($_[0]))  {
+
+    if (exists $_[1] || !ref($_[0]))  {
         $entry = [@_];
-    } else { 
+    } else {
         $entry = shift @_;
     }
-       my  $content = to_json($entry, { canonical => 1, pretty=> 0, utf8=>1, allow_nonref => 0}  );
-    
-    
+
+    my $content = to_json($entry, {
+        canonical    => 1,
+        pretty       => 0,
+        utf8         => 1,
+        allow_nonref => 0,
+    });
+
+    my %props = (
+        content => $content,
+        label   => $self->label,
+    );
+
     if ($self->handle->record_exists( uuid => $self->uuid, type => $self->type)) {
-        $self->set_props( props => { content => $content, label => $self->label});
-    } else {
-        $self->_create_record( props => { content => $content, label => $self->label }, uuid => $self->uuid );
+        $self->set_props(props => \%props);
+    }
+    else {
+        $self->_create_record(
+            uuid  => $self->uuid,
+            props => \%props,
+        );
     }
 }
 
-
-
 sub get_raw {
     my $self = shift;
     my $content = $self->prop('content');
@@ -65,11 +79,13 @@
     $self->initialize() unless $self->load(uuid => $self->uuid);
     my $content = $self->get_raw;
 
-    my $entry = from_json($content , { utf8 => 1 });
+    my $entry = from_json($content, { utf8 => 1 });
     return $entry;
     # XXX TODO do we really want to just get the first one?
-
 }
-1;
 
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
 



More information about the Bps-public-commit mailing list