.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Bread::Board::Service 3pm" .TH Bread::Board::Service 3pm "2022-12-12" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Bread::Board::Service \- Base service role .SH "VERSION" .IX Header "VERSION" version 0.37 .SH "DESCRIPTION" .IX Header "DESCRIPTION" 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. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .ie n .SS """name""" .el .SS "\f(CWname\fP" .IX Subsection "name" Read/write string, required. Every service needs a name, by which it can be referenced when fetching it. .ie n .SS """is_locked""" .el .SS "\f(CWis_locked\fP" .IX Subsection "is_locked" Boolean, defaults to false. Used during dependency resolution to detect loops. .ie n .SS """lifecycle""" .el .SS "\f(CWlifecycle\fP" .IX Subsection "lifecycle" .Vb 1 \& $service\->lifecycle(\*(AqSingleton\*(Aq); .Ve .PP Read/write string; it should be either a partial class name under the \&\f(CW\*(C`Bread::Board::LifeCycle::\*(C'\fR namespace (like \f(CW\*(C`Singleton\*(C'\fR for \&\f(CW\*(C`Bread::Board::LifeCycle::Singleton\*(C'\fR) or a full class name prefixed with \f(CW\*(C`+\*(C'\fR (like \f(CW\*(C`+My::Special::Lifecycle\*(C'\fR). The name is expected to refer to a loadable \fIrole\fR, which will be applied to the service instance. .SH "METHODS" .IX Header "METHODS" .ie n .SS """lock""" .el .SS "\f(CWlock\fP" .IX Subsection "lock" Locks the service; you should never need to call this method in normal code. .ie n .SS """unlock""" .el .SS "\f(CWunlock\fP" .IX Subsection "unlock" Unlocks the service; you should never need to call this method in normal code. .ie n .SS """get""" .el .SS "\f(CWget\fP" .IX Subsection "get" .Vb 1 \& my $value = $service\->get(); .Ve .PP This method \fImust\fR be implemented by the consuming class. It's expected to instantiate whatever object or value this service should resolve to. .ie n .SS """init_params""" .el .SS "\f(CWinit_params\fP" .IX Subsection "init_params" Builder for the service parameters, defaults to returning an empty hashref. .ie n .SS """clear_params""" .el .SS "\f(CWclear_params\fP" .IX Subsection "clear_params" Clearer of the service parameters. .ie n .SS """param""" .el .SS "\f(CWparam\fP" .IX Subsection "param" .Vb 3 \& my @param_names = $service\->param(); \& my $param_value = $service\->param($param_name); \& $service\->param($name1=>$value1,$name2=>$value2); .Ve .PP Getter/setter for the service parameters; notice that calling this method with no arguments returns the list of parameter names. .PP \&\fIPlease note\fR: these are not the same as the parameters for a parametric service (although those will be copied here before \f(CW\*(C`get\*(C'\fR is called), nor are they the same thing as dependencies (although the resolved dependencies will be copied here before \f(CW\*(C`get\*(C'\fR is called). .ie n .SS """clone_and_inherit_params""" .el .SS "\f(CWclone_and_inherit_params\fP" .IX Subsection "clone_and_inherit_params" When declaring a service using the \f(CW\*(C`service\*(C'\fR helper function, if the name you use starts with a \&\f(CW\*(Aq+\*(Aq\fR, the service definition will extend an existing service with the given name (without the \f(CW\*(Aq+\*(Aq\fR). This method implements the extension semantics: the \f(CW\*(C`dependencies\*(C'\fR and \f(CW\*(C`parameters\*(C'\fR options will be merged with the existing values, rather than overridden. .SH "AUTHOR" .IX Header "AUTHOR" Stevan Little .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests on the bugtracker website https://github.com/stevan/BreadBoard/issues .PP 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. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2019, 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.