From d4fc09d937d7afb2d08ab4badca26426d78944da Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 26 Jan 2012 17:28:16 -0600 Subject: document the container trait --- .../Board/Declare/Meta/Role/Attribute/Container.pm | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'lib/Bread/Board/Declare') diff --git a/lib/Bread/Board/Declare/Meta/Role/Attribute/Container.pm b/lib/Bread/Board/Declare/Meta/Role/Attribute/Container.pm index 6fa68ad..1b5ab6d 100644 --- a/lib/Bread/Board/Declare/Meta/Role/Attribute/Container.pm +++ b/lib/Bread/Board/Declare/Meta/Role/Attribute/Container.pm @@ -1,9 +1,48 @@ package Bread::Board::Declare::Meta::Role::Attribute::Container; use Moose::Role; Moose::Util::meta_attribute_alias('Container'); +# ABSTRACT: attribute metarole for container attributes in Bread::Board::Declare use Class::Load 'load_class'; +=head1 DESCRIPTION + +This attribute trait indicates that the attribute (in a +L class) contains a subcontainer rather than a service. +It must be specified explicitly (or else a service that happens to return a +container will be created): + + has attr => ( + traits => ['Container'], + is => 'ro', + isa => 'Bread::Board::Container', + ); + +Container attributes (unlike service attributes) can have defaults and +builders, allowing you to also define subcontainers inline when desired, as in: + + has attr => ( + traits => ['Container'], + is => 'ro', + isa => 'Bread::Board::Container', + default => sub { + container Foo => as { + service Bar => 'BAR'; + }; + } + ); + +=cut + +=attr dependencies + +If no default or builder is supplied, the type constraint will be used to +create a container instance automatically (using a temporary +L service). This is +the dependency specification to use for that temporary service. + +=cut + has dependencies => ( is => 'ro', isa => 'Bread::Board::Service::Dependencies', -- cgit v1.2.3