Commit | Line | Data |
7adfd53f |
1 | package # hide from PAUSE |
2 | RTest::TestDB::Baz; |
3 | |
082e6aee |
4 | use Moose; |
3cbb53fc |
5 | extends 'DBIx::Class::Core'; |
7adfd53f |
6 | |
99535516 |
7 | use MooseX::Types::Moose qw/ArrayRef Int Bool Str/; |
baee102d |
8 | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; |
7adfd53f |
9 | |
082e6aee |
10 | has 'id' => (isa => Int, is => 'ro', required => 1); |
ed6d9da8 |
11 | has 'name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1); |
99535516 |
12 | has 'description' => (isa => Str, is => 'rw',); |
c2f0e9e9 |
13 | has 'bool_field' => (isa => Bool, is => 'rw', required => 0); |
510f6c25 |
14 | has 'foo_list' => ( |
13312031 |
15 | isa => ArrayRef, |
16 | is => 'rw', |
17 | required => 1, |
18 | writer => 'set_foo_list', |
19 | reader => 'get_foo_list', |
20 | ); |
510f6c25 |
21 | |
22 | around get_foo_list => sub { [ $_[1]->foo_list->all ] }; |
7adfd53f |
23 | |
082e6aee |
24 | use namespace::clean -except => [ 'meta' ]; |
7adfd53f |
25 | |
26 | __PACKAGE__->table('baz'); |
27 | |
28 | __PACKAGE__->add_columns( |
29 | id => { data_type => 'integer', size => 16, is_auto_increment => 1 }, |
30 | name => { data_type => 'varchar', size => 255 }, |
99535516 |
31 | description => { data_type => 'text', is_nullable => 1 }, |
c2f0e9e9 |
32 | bool_field => { |
33 | data_type => 'char', |
34 | size => '1', |
35 | is_nullable => '1' |
36 | } |
7adfd53f |
37 | ); |
38 | |
7adfd53f |
39 | __PACKAGE__->set_primary_key('id'); |
40 | |
41 | __PACKAGE__->has_many('links_to_foo_list' => 'RTest::TestDB::FooBaz', 'baz'); |
42 | __PACKAGE__->many_to_many('foo_list' => 'links_to_foo_list' => 'foo'); |
43 | |
082e6aee |
44 | sub display_name { shift->name; } |
45 | |
c689b58e |
46 | __PACKAGE__->meta->make_immutable(inline_constructor => 0); |
a5200252 |
47 | |
7adfd53f |
48 | 1; |