Commit | Line | Data |
7adfd53f |
1 | package # hide from PAUSE |
2 | RTest::TestDB::Bar; |
3 | |
082e6aee |
4 | use Moose; |
3cbb53fc |
5 | extends 'DBIx::Class'; |
7adfd53f |
6 | |
599c1172 |
7 | use aliased 'RTest::TestDB::Foo'; |
baee102d |
8 | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; |
9 | use MooseX::Types::DateTime qw/DateTime/; |
ed6d9da8 |
10 | use Reaction::Types::File 'File'; |
7adfd53f |
11 | |
ed6d9da8 |
12 | has 'name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1); |
599c1172 |
13 | has 'foo' => (isa => Foo, is => 'rw', required => 1); |
baee102d |
14 | has 'published_at' => (isa => DateTime, is => 'rw'); |
ed6d9da8 |
15 | has 'avatar' => (isa => File, is => 'rw'); |
7adfd53f |
16 | |
082e6aee |
17 | use namespace::clean -except => [ 'meta' ]; |
18 | |
7adfd53f |
19 | __PACKAGE__->load_components(qw/InflateColumn::DateTime Core/); |
20 | |
21 | __PACKAGE__->table('bar'); |
22 | |
23 | __PACKAGE__->add_columns( |
24 | name => { data_type => 'varchar', size => 255 }, |
25 | foo_id => { data_type => 'integer', size => 16 }, |
26 | published_at => { data_type => 'datetime', is_nullable => 1 }, |
27 | avatar => { data_type => 'blob', is_nullable => 1 }, |
28 | ); |
29 | |
30 | __PACKAGE__->set_primary_key('name'); |
31 | |
32 | __PACKAGE__->belongs_to( |
599c1172 |
33 | 'foo' => Foo, |
7adfd53f |
34 | { 'foreign.id' => 'self.foo_id' } |
35 | ); |
36 | |
082e6aee |
37 | sub display_name{ shift->name } |
38 | |
c689b58e |
39 | __PACKAGE__->meta->make_immutable(inline_constructor => 0); |
a5200252 |
40 | |
7adfd53f |
41 | 1; |