I use Moose a lot and can probably help you, but I'm not sure I understand your question.
You said: ...needing "sub" objects regularly. What is a "sub" object to you? What I see in your code is that MyApp (My::App object) is an attribute of the "My" class. Is that what you call a sub object?
Also: How do you deal with passing required attributes through? ... You mean through the "sub" object? If you want to pass your required attributes from the "My" object to the "MyApp" attribute, I recommend using a "lazy" attribute with a "builder". Try this (you can get fancy later):
has 'MyApp' => ( lazy => 1, isa => 'My::App', builder => '_build_myapp', ); sub _build_myapp { my $self = shift; return My::App->new( foo => $self->app_foo, bar => $self->app_bar, ); };
It's much cleaner.
In reply to Re: [Moose] Critique request on my Moose design (anti?)pattern
by greengaroo
in thread [Moose] Critique request on my Moose design (anti?)pattern
by three18ti
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |