Fix componentUI so that it compiles. Make a couple of the tests which don't work...
[catagits/Reaction.git] / t / lib / RTest / TestDB / Foo.pm
CommitLineData
7adfd53f 1package # hide from PAUSE
2 RTest::TestDB::Foo;
3
df9a9c12 4use base qw/DBIx::Class/;
082e6aee 5use metaclass 'Reaction::Meta::Class';
6use Moose;
7adfd53f 7
082e6aee 8use MooseX::Types::Moose qw/ArrayRef Int/;
9use Reaction::Types::Core qw/NonEmptySimpleStr/;
7adfd53f 10
082e6aee 11has 'id' => (isa => Int, is => 'ro', required => 1);
ed6d9da8 12has 'first_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1);
13has 'last_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1);
80436b58 14has 'bars' => (isa => ArrayRef, is => 'ro' );
df9a9c12 15has 'bazes' =>
082e6aee 16 (
17 isa => ArrayRef,
18 required => 1,
df9a9c12 19 reader => 'get_bazes',
20 writer => 'set_bazes'
7adfd53f 21);
22
082e6aee 23use namespace::clean -except => [ 'meta' ];
7adfd53f 24
df9a9c12 25__PACKAGE__->load_components(qw/IntrospectableM2M Core/);
7adfd53f 26__PACKAGE__->table('foo');
27
28__PACKAGE__->add_columns(
29 id => { data_type => 'integer', size => 16, is_auto_increment => 1 },
30 first_name => { data_type => 'varchar', size => 255 },
31 last_name => { data_type => 'varchar', size => 255 },
32);
33
7adfd53f 34__PACKAGE__->set_primary_key('id');
35
510f6c25 36__PACKAGE__->has_many(
37 'bars' => 'RTest::TestDB::Bar',
38 { 'foreign.foo_id' => 'self.id' }
39 );
40
df9a9c12 41__PACKAGE__->has_many('foo_baz' => 'RTest::TestDB::FooBaz', 'foo');
42__PACKAGE__->many_to_many('bazes' => 'foo_baz' => 'baz');
7adfd53f 43
082e6aee 44sub display_name {
45 my $self = shift;
46 return join(' ', $self->first_name, $self->last_name);
7adfd53f 47}
48
510f6c25 49around get_bazes => sub { [ $_[1]->bazes_rs->all ] };
a5200252 50
c689b58e 51__PACKAGE__->meta->make_immutable(inline_constructor => 0);
a5200252 52
7adfd53f 531;