Bread::Board::Service - Base service role
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
Bread::Board::LifeCycle::Singleton) or a full class name prefixed with
+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); $service->param($name1=>$value1,$name2=>$value2);
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
parameters options will be merged with the existing values, rather than overridden.
Stevan Little <email@example.com>
Please report any bugs or feature requests on the bugtracker website https://github.com/stevan/BreadBoard/issues
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) 2016 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.