Bread:...ameters(3pm)
π Bread:...ameters(3pm) β User Contributed Perl Documentation π
okay bestie, welcome to the manual page for Bread::Board::Service::WithParameters, served up fresh from the User Contributed Perl Documentation collection, section 3pm. pull up a chair, grab a boba, we're doing parameterized services today and it's gonna be iconic π§β¨
πΈ NAME πΈ
Bread::Board::Service::WithParameters β services with parameters, periodt.
π VERSION π
version 0.37 π
π¦ DESCRIPTION π¦
so this is a sub-role of Bread::Board::Service, and it exists specifically for parameterized services. what's that mean? it means these services will instantiate different values depending on parameters that get passed to the get method. it's giving β¨customizationβ¨
and how do you actually pass those parameters in? two ways, bestie:
- through the
service_paramsattribute ofBread::Board::Dependency - or through the
inflatemethod ofBread::Board::Service::Deferred::Thunk
pick your fighter, they both slay π
β¨ ATTRIBUTES β¨
π parameters
read-only hashref, and it gets passed as-is straight into MooseX::Params::Validate's validated_hash. which is huge, because it means you get to use things like optional and default on top of your regular type constraints. no cap.
like, check this out:
service something => (
class => 'Thing',
parameters => {
type => { isa => 'Str', default => 'text' },
},
);
okay but here's the cute part π β this attribute uses coercions on Bread::Board::Service::Parameters, so you can ALSO just say:
service something => (
class => 'Thing',
parameters => ['type'],
);
and bestie, that is equivalent to:
service something => (
class => 'Thing',
parameters => {
type => { optional => 0 },
},
);
same energy, way less typing. the way that worksβ¦ we love efficiency π
π METHODS π
has_parameters
predicate for the parameters attribute. classic predicate behaviour, nothing spicy.
has_parameter_defaults
returns true if any of the parameters have a default value. that's it, that's the method β¨
has_required_parameters
returns true if any of the parameters does not have optional set to true. so if even one of them is mandatory, this goes true. main character parameter energy fr fr π
check_parameters
my %parameters = $service->check_parameters(name1=>$value1,name2=>$value2);
my %parameters = $service->check_parameters({name1=>$value1,name2=>$value2});
if any parameters are defined, this function validates its arguments against the parameters' definitions (using MooseX::Params::Validate). and then:
β οΈ it will die if the validation fails π no coming back from that one.
but if it succeeds? it returns the validated parameters β including default values β and everything is fine and beautiful π
get
okay so before the get method runs, the arguments going into get get passed through check_parameters and then added to the params hashref. and after the get method runs, those keys/values get removed again. clean up after yourself, we stan a tidy queen π
in practice? this makes all parameters available to the actual get method body. so your get body just⦠has them. iconic behaviour, honestly.
π«Ά AUTHOR π«Ά
Stevan Little <stevan@iinteractive.com>
π BUGS π
please report any bugs or feature requests on the bugtracker website
https://github.com/stevan/BreadBoard/issues
and when you're submitting a bug or a request, bestie, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. it's giving help us help you πβ¨
π COPYRIGHT AND LICENSE π
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. slay, open source π
and that's the whole page, bestie!! π this one was rendered by perl v5.36.0 on 2022-12-12, and yeah the title line got truncated to Bread:...ameters(3pm) because apparently even manpages have a character limit π go forth and parameterize responsibly π¦β¨
π¦ where this page comes from
- debian bookworm: libbread-board-perl 0.37-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libbread-board-perl 0.37-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbread-board-perl 0.37-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libbread-board-perl 0.37-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms