使用Bread::Board我有一个A
带有访问器的对象/服务$A->foo
。对象/服务 B 依赖于$A->Foo
它的构造函数。我该怎么做?这是我所拥有的一个例子
use Moose;
use Bread::Board;
has info => ( is => 'ro', lazy => 1, isa => 'Str', default => sub { 'something' } );
extends 'Bread::Board::Container';
sub BUILD {
my $self = shift;
container $self => as {
service info => $self->info;
service A => (
class => 'A',
dependencies => {
info => depends_on('info'),
},
);
service B => (
class => 'B',
dependencies => {
foo => depends_on('foo'), # foo could be gotten by
}, # ->resolve( service => 'A' )->foo
); # e.g foo is an accessor on A
};
}
我不确定我可以添加或应该添加什么代码来完成这项工作。