C:\Perl_PPM\Bread-Board-0.33\blib/lib/Bread/Board/Service.pm |
Bread::Board::Service
version 0.33
This role is the basis for all services in the Bread::Board manpage. It provides (or requires the implementation of) the minimum necessary building blocks: creating an instance, setting/getting parameters, instance lifecycle.
name
Read/write string, required. Every service needs a name, by which it can be referenced when fetching it.
is_locked
Boolean, defaults to false. Used during dependency resolution to detect loops.
lifecycle
$service->lifecycle('Singleton');
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.
lock
Locks the service; you should never need to call this method in normal code.
unlock
Unlocks the service; you should never need to call this method in normal code.
get
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.
init_params
Builder for the service parameters, defaults to returning an empty hashref.
clear_params
Clearer of the service parameters.
param
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).
clone_and_inherit_params
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 <stevan@iinteractive.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) 2015 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.
C:\Perl_PPM\Bread-Board-0.33\blib/lib/Bread/Board/Service.pm |