add get_columns and set_columns methods to Row.pm
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Row.pm
index 4308e9c..38f6a82 100644 (file)
@@ -176,6 +176,19 @@ sub get_column {
   return undef;
 }
 
+=item get_columns
+
+  my %data = $obj->get_columns;
+
+Fetch all column values at once.
+
+=cut
+
+sub get_columns {
+  my $self = shift;
+  return map { $_ => $self->get_column($_) } $self->columns;
+}
+
 =item set_column
 
   $obj->set_column($col => $val);
@@ -194,6 +207,29 @@ sub set_column {
   return $ret;
 }
 
+=item set_columns
+
+  my $copy = $orig->copy({ $col => $val, ... });
+
+Set more than one column value at once.
+
+=cut
+
+sub set_columns {
+  my ($self,$data) = @_;
+  while (my ($col,$val) = each %$data) {
+    $self->set_column($col,$val);
+  }
+}
+
+=item copy
+
+  my $copy = $orig->copy({ change => $to, ... });
+
+Insert a new row with the specified changes.
+
+=cut
+
 =item store_column
 
   $obj->store_column($col => $val);
@@ -220,12 +256,6 @@ sub _row_to_object {
   return $new;
 }
 
-=item copy
-
-  my $copy = $orig->copy({ change => $to, ... });
-
-=cut
-
 sub copy {
   my ($self, $changes) = @_;
   my $new = bless({ _column_data => { %{$self->{_column_data}}} }, ref $self);