ditching the COMPONENT constructor
André Walker [Wed, 10 Aug 2011 03:55:39 +0000 (00:55 -0300)]
t/lib/TestAppCustomContainer/Model/Bar.pm
t/lib/TestAppCustomContainer/Model/Baz.pm
t/lib/TestAppCustomContainer/Role/HoldsFoo.pm

index 86dcfd2..1c92392 100644 (file)
@@ -4,6 +4,12 @@ extends 'Catalyst::Model';
 with 'TestAppCustomContainer::Role::HoldsFoo',
      'TestAppCustomContainer::Role::ACCEPT_CONTEXT';
 
+sub BUILD {
+    my ( $self ) = @_;
+
+    $self->foo->inc_bar_got_it;
+}
+
 __PACKAGE__->meta->make_immutable;
 
 no Moose;
index 2efb1f5..fa475e6 100644 (file)
@@ -4,6 +4,12 @@ extends 'Catalyst::Model';
 with 'TestAppCustomContainer::Role::HoldsFoo',
      'TestAppCustomContainer::Role::ACCEPT_CONTEXT';
 
+sub BUILD {
+    my ( $self ) = @_;
+
+    $self->foo->inc_baz_got_it;
+}
+
 __PACKAGE__->meta->make_immutable;
 
 no Moose;
index a51f948..9e0aeba 100644 (file)
@@ -8,13 +8,4 @@ has foo => (
     required => 1,
 );
 
-sub COMPONENT {
-    my ( $self, $ctx, $config ) = @_;
-
-    # FIXME - is this how should I get model Foo?
-    return $self->new(
-        foo => $ctx->model('Foo'),
-    );
-}
-
 1;