Scroll to navigation

Bread::Board::Service(3pm) User Contributed Perl Documentation Bread::Board::Service(3pm)


Bread::Board::Service - Base service role


version 0.37


This role is the basis for all services in Bread::Board. It provides (or requires the implementation of) the minimum necessary building blocks: creating an instance, setting/getting parameters, instance lifecycle.



Read/write string, required. Every service needs a name, by which it can be referenced when fetching it.


Boolean, defaults to false. Used during dependency resolution to detect loops.



Read/write string; it should be either a partial class name under the "Bread::Board::LifeCycle::" namespace (like "Singleton" for "Bread::Board::LifeCycle::Singleton") or a full class name prefixed with "+" (like "+My::Special::Lifecycle"). The name is expected to refer to a loadable role, which will be applied to the service instance.



Locks the service; you should never need to call this method in normal code.


Unlocks the service; you should never need to call this method in normal code.


  my $value = $service->get();

This method must be implemented by the consuming class. It's expected to instantiate whatever object or value this service should resolve to.


Builder for the service parameters, defaults to returning an empty hashref.


Clearer of the service parameters.


  my @param_names = $service->param();
  my $param_value = $service->param($param_name);

Getter/setter for the service parameters; notice that calling this method with no arguments returns the list of parameter names.

Please note: these are not the same as the parameters for a parametric service (although those will be copied here before "get" is called), nor are they the same thing as dependencies (although the resolved dependencies will be copied here before "get" is called).


When declaring a service using the "service" helper function, if the name you use starts with a '+', the service definition will extend an existing service with the given name (without the '+'). This method implements the extension semantics: the "dependencies" and "parameters" options will be merged with the existing values, rather than overridden.


Stevan Little <>


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


This software is copyright (c) 2019, 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2020-04-01 perl v5.30.0