Separate out App::IdiotBox::* DB objects and put create/update
[catagits/App-IdiotBox.git] / lib / App / IdiotBox / Importer.pm
index 4600777..f0d0967 100644 (file)
@@ -41,15 +41,20 @@ sub run {
         my $sn = prompt("What's the new short name (url path) for the slug ?");
         my $ln = prompt("What's the new long name (description) for the slug ?");
 
-        $sn =~ s/ /-/g;
-
-        my $nb = $ib->buckets->add(bless({
+        my ($nb, $err) = App::IdiotBox::Bucket->create(
           slug => $sn,
           name => $ln,
-        }, 'App::IdiotBox::Bucket'));
+        );
+
+        if ($err) {
+          log_info { "Error creating new bucket: $err" };
+          redo CHOOSE;
+        }
+
+        my $rnb = $ib->buckets->add($nb);
 
         log_info { "Created new bucket" };
-        push @buckets, $nb;
+        push @buckets, $rnb;
         redo BUCKETS;
       }