DESCRIPTION

This module is a Moose extension which allows for declaring Bread::Board container classes in a more straightforward and natural way. It sets up Bread::Board::Container as the superclass, and creates services associated with each attribute that you create, according to these rules:

If the block option is passed to has, a Bread::Board::BlockInjection service is created, with the given coderef as the block. In addition to receiving the service object (as happens in Bread::Board), this coderef will also be passed the container object.

If the attribute has a type constraint corresponding to a class, a Bread::Board::ConstructorInjection service is created, with the class corresponding to the type constraint.

Otherwise, a BlockInjection service is created which throws an exception. This allows services to be created for the sole purpose of being set through the attribute, without requiring a default to be specified. Note that required => 1 is still valid on these attributes.

Constructor parameters for services (dependencies, lifecycle, etc) can also be passed into the attribute definition; these will be forwarded to the service constructor. See Bread::Board::Declare::Meta::Role::Attribute::Service for a full list of additional parameters to has.

If infer => 1 is passed in the attribute definition, the class in the type constraint will be introspected to find its required dependencies, and those dependencies will be automatically fulfilled as much as possible by corresponding services in the container. See Bread::Board::Manual::Concepts::Typemap for more information.

In addition to creating the services, this module also modifies the attribute reader generation, so that if the attribute has no value, a value will be resolved from the associated service. It also modifies the get method on services so that if the associated attribute has a value, that value will be returned immediately. This allows for overriding service values by passing replacement values into the constructor, or by calling setter methods.

Note that default/builder doesn't make a lot of sense in this setting, so they are explicitly disabled. In addition, multiple inheritance would just cause a lot of problems, so it is also disabled (although single inheritance and role application works properly).

EXPORTS

dep

dependencies => {
foo => dep('foo'),
bar => dep(value => 'bar'),
}

This is a helper function for specifying dependency lists. Passing a single argument will explicitly mark it as a dependency to be resolved by looking it up in the container. This isn't strictly necessary (the dependency specifications for Bread::Board have a coercion which does this automatically), but being explicit can be easier to understand at times.

This function can also take a hash of arguments. In that case, an anonymous service is created to satisfy the dependency. The hash is passed directly to the constructor for the appropriate service: if the value parameter is passed, a Bread::Board::Literal service will be created, if the block parameter is passed, a Bread::Board::BlockInjection service will be created, and if the class parameter is passed, a Bread::Board::ConstructorInjection service will be created. Note that these anonymous services cannot have dependencies themselves, nor can they be depended on by other services.

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.