File: GetSet.pm

package info (click to toggle)
libdbix-class-perl 0.082844-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,320 kB
  • sloc: perl: 27,215; sql: 322; sh: 29; makefile: 16
file content (30 lines) | stat: -rw-r--r-- 607 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package # hide from PAUSE
    DBIx::Class::CDBICompat::GetSet;

use strict;
use warnings;

sub get {
  my ($self, @cols) = @_;
  if (@cols > 1) {
    return map { $self->get_column($_) } @cols;
  } else {
    return $self->get_column($_[1]);
  }
}

sub set {
  my($self, %data) = @_;

  # set_columns() is going to do a string comparison before setting.
  # This breaks on DateTime objects (whose comparison is arguably broken)
  # so we stringify anything first.
  for my $key (keys %data) {
    next unless ref $data{$key};
    $data{$key} = "$data{$key}";
  }

  return shift->set_columns(\%data);
}

1;