File: Encoded.pm

package info (click to toggle)
libdbix-class-perl 0.082841-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 5,236 kB
  • sloc: perl: 26,763; sql: 322; makefile: 10
file content (41 lines) | stat: -rw-r--r-- 834 bytes parent folder | download | duplicates (5)
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
31
32
33
34
35
36
37
38
39
40
41
package # hide from PAUSE
    DBICTest::Schema::Encoded;

use strict;
use warnings;

use base qw/DBICTest::BaseResult/;

__PACKAGE__->table('encoded');
__PACKAGE__->add_columns(
    'id' => {
        data_type => 'integer',
        is_auto_increment => 1
    },
    'encoded' => {
        data_type => 'varchar',
        size      => 100,
        is_nullable => 1,
    },
);

__PACKAGE__->set_primary_key('id');

__PACKAGE__->has_many (keyholders => 'DBICTest::Schema::Employee', 'encoded');

sub set_column {
  my ($self, $col, $value) = @_;
  if( $col eq 'encoded' ){
    $value = reverse split '', $value;
  }
  $self->next::method($col, $value);
}

sub new {
  my($self, $attr, @rest) = @_;
  $attr->{encoded} = reverse split '', $attr->{encoded}
    if defined $attr->{encoded};
  return $self->next::method($attr, @rest);
}

1;