Separate out App::IdiotBox::* DB objects and put create/update
[catagits/App-IdiotBox.git] / lib / App / IdiotBox / Clonable.pm
diff --git a/lib/App/IdiotBox/Clonable.pm b/lib/App/IdiotBox/Clonable.pm
new file mode 100644 (file)
index 0000000..3852caf
--- /dev/null
@@ -0,0 +1,19 @@
+package App::IdiotBox::Clonable;
+
+use Moo::Role;
+
+sub clone {
+       my $obj = shift;
+
+       my $class = ref $obj;
+
+       my %copy;
+
+       for my $f ($obj->fields) {
+               $copy{$f} = $obj->$f,
+       };
+
+       return bless \%copy, $class;
+}
+
+1;