use MooseX::Types::Common and MooseX::Types::DateTime
[catagits/Reaction.git] / t / lib / RTest / TestDB / Bar.pm
CommitLineData
7adfd53f 1package # hide from PAUSE
2 RTest::TestDB::Bar;
3
082e6aee 4use Moose;
3cbb53fc 5extends 'DBIx::Class';
7adfd53f 6
599c1172 7use aliased 'RTest::TestDB::Foo';
baee102d 8use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
9use MooseX::Types::DateTime qw/DateTime/;
ed6d9da8 10use Reaction::Types::File 'File';
7adfd53f 11
ed6d9da8 12has 'name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1);
599c1172 13has 'foo' => (isa => Foo, is => 'rw', required => 1);
baee102d 14has 'published_at' => (isa => DateTime, is => 'rw');
ed6d9da8 15has 'avatar' => (isa => File, is => 'rw');
7adfd53f 16
082e6aee 17use 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 37sub display_name{ shift->name }
38
c689b58e 39__PACKAGE__->meta->make_immutable(inline_constructor => 0);
a5200252 40
7adfd53f 411;