use MooseX::Types::Common and MooseX::Types::DateTime
[catagits/Reaction.git] / t / lib / RTest / TestDB / Bar.pm
1 package # hide from PAUSE
2   RTest::TestDB::Bar;
3
4 use Moose;
5 extends 'DBIx::Class';
6
7 use aliased 'RTest::TestDB::Foo';
8 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
9 use MooseX::Types::DateTime qw/DateTime/;
10 use Reaction::Types::File 'File';
11
12 has 'name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1);
13 has 'foo' => (isa => Foo, is => 'rw', required => 1);
14 has 'published_at' => (isa => DateTime, is => 'rw');
15 has 'avatar' => (isa => File, is => 'rw');
16
17 use namespace::clean -except => [ 'meta' ];
18
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(
33   'foo' => Foo,
34   { 'foreign.id' => 'self.foo_id' }
35 );
36
37 sub display_name{ shift->name }
38
39 __PACKAGE__->meta->make_immutable(inline_constructor => 0);
40
41 1;