57330548e6e895411cbfb087380fa87a320f5885
[catagits/Reaction.git] / t / lib / RTest / TestDB / Foo.pm
1 package # hide from PAUSE
2   RTest::TestDB::Foo;
3
4 use DBIx::Class 0.07;
5
6 use base qw/DBIx::Class Reaction::Object/;
7 use Reaction::Class;
8
9 has 'id' => (isa => 'Int', is => 'ro', required => 1);
10 has 'first_name' => (isa => 'NonEmptySimpleStr', is => 'rw', required => 1);
11 has 'last_name' => (isa => 'NonEmptySimpleStr', is => 'rw', required => 1);
12 has 'baz_list' => (
13   isa => 'ArrayRef', is => 'rw', required => 1,
14   reader => 'get_baz_list', writer => 'set_baz_list'
15 );
16
17 __PACKAGE__->load_components(qw/InflateColumn::DateTime Core/);
18
19 __PACKAGE__->table('foo');
20
21 __PACKAGE__->add_columns(
22   id => { data_type => 'integer', size => 16, is_auto_increment => 1 },
23   first_name => { data_type => 'varchar', size => 255 },
24   last_name => { data_type => 'varchar', size => 255 },
25 );
26
27 sub display_name {
28   my $self = shift;
29   return join(' ', $self->first_name, $self->last_name);
30 }
31
32 __PACKAGE__->set_primary_key('id');
33
34 __PACKAGE__->has_many('links_to_baz_list' => 'RTest::TestDB::FooBaz', 'foo');
35 __PACKAGE__->many_to_many('baz_list' => 'links_to_baz_list' => 'baz');
36
37 {
38   no warnings 'redefine';
39   *get_baz_list = sub { [ shift->baz_list->all ] };
40 }
41
42 1;