e5576adafe559e879f864feb6b750795c68fea48
[dbsrgits/DBIx-Class-UserStamp.git] / t / lib / DBIC / Test / Schema / Accessor.pm
1 package #
2     DBIC::Test::Schema::Accessor;
3
4 use base 'DBIx::Class::Core';
5
6 __PACKAGE__->load_components(qw/UserStamp PK::Auto Core/);
7 __PACKAGE__->table('test_accessor');
8
9 __PACKAGE__->add_columns(
10     'pk1' => {
11         data_type => 'integer', is_nullable => 0, is_auto_increment => 1
12     },
13     display_name => { data_type => 'varchar', size => 128, is_nullable => 0 },
14     u_created => {
15         data_type => 'integer', is_nullable => 0,
16         store_user_on_create => 1, accessor => 'u_created_accessor',
17     },
18     u_updated => {
19         data_type => 'integer', is_nullable => 0,
20         store_user_on_create => 1, store_user_on_update => 1, accessor => 'u_updated_accessor',
21     },
22 );
23
24 __PACKAGE__->set_primary_key('pk1');
25
26 no warnings 'redefine';
27
28 sub u_created {
29     my $self = shift;
30     croak('Shouldnt be trying to update through u_created - should use accessor') if shift;
31
32     return $self->u_created_accessor();
33 }
34
35 sub u_updated {
36     my $self = shift;
37     croak('Shouldnt be trying to update through u_updated - should use accessor') if shift;
38
39     return $self->u_updated_accessor();
40 }
41
42
43 1;