has 'id' => (isa => Int, is => 'ro', required => 1);
has 'name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1);
-has 'foo_list' => (isa => ArrayRef, is => 'ro', required => 1);
+has 'foo_list' => (
+ isa => ArrayRef,
+ is => 'rw',
+ required => 1,
+ writer => 'set_foo_list',
+ reader => 'get_foo_list',
+ );
+
+around get_foo_list => sub { [ $_[1]->foo_list->all ] };
use namespace::clean -except => [ 'meta' ];
has 'id' => (isa => Int, is => 'ro', required => 1);
has 'first_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1);
has 'last_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1);
+has 'bars' => (isa => ArrayRef );
has 'bazes' =>
(
isa => ArrayRef,
__PACKAGE__->set_primary_key('id');
+__PACKAGE__->has_many(
+ 'bars' => 'RTest::TestDB::Bar',
+ { 'foreign.foo_id' => 'self.id' }
+ );
+
__PACKAGE__->has_many('foo_baz' => 'RTest::TestDB::FooBaz', 'foo');
__PACKAGE__->many_to_many('bazes' => 'foo_baz' => 'baz');
return join(' ', $self->first_name, $self->last_name);
}
-sub get_bazes { [ shift->bazes_rs->all ] };
+around get_bazes => sub { [ $_[1]->bazes_rs->all ] };
__PACKAGE__->meta->make_immutable(inline_constructor => 0);