Bread:...Service(3pm)

πŸ“¦
version 0.37 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– Bread::Board::Service β€” bestie edition πŸ’–

okay so this is the Bread::Board::Service page from the User Contributed Perl Documentation (that's the manual name, it's giving 3pm energy ✨). Sit down, grab a strawberry πŸ“, we're learning.


🌸 NAME 🌸

Bread::Board::Service β€” the Base service role, periodt. It's the blueprint every service in the family is built on πŸ‘‘


✨ VERSION ✨

version 0.37 β€” no cap, that's the number πŸŽ€


πŸ’… DESCRIPTION πŸ’…

This role is the basis for all services in Bread::Board. Think of it as the main character that everyone else takes after. It provides β€” or requires you to implement β€” the absolute minimum necessary building blocks, which are:

  • creating an instance 🐣
  • setting/getting parameters πŸ“
  • instance lifecycle πŸ”„

That's it, that's the whole vibe.


πŸ¦‹ ATTRIBUTES πŸ¦‹

"name"

Read/write string, required ⚠️. Every single service needs a name, bestie. It's how you reference the service when you're fetching it. No name = no entry, sorry 🚫

"is_locked"

Boolean, defaults to false. This one is used during dependency resolution to detect loops πŸŒ€. It's the vibe check that catches circular nonsense.

"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 a + (like +My::Special::Lifecycle). The name is expected to refer to a loadable role, which will be applied to the service instance. slay πŸ’«


πŸ”₯ METHODS πŸ”₯

"lock"

Locks the service. You should never need to call this method in normal code πŸ™ˆ. It's giving internal-business-only.

"unlock"

Unlocks the service. Same deal β€” you should never need to call this method in normal code πŸ™ˆ. Hands off, bestie.

"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. You're on your own for this one, queen.

"init_params"

Builder for the service parameters. Defaults to returning an empty hashref {} πŸͺ£

"clear_params"

Clearer of the service parameters. Bye bye params πŸ‘‹

"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 β€” and this is the important part β€” 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), and they are also not the same thing as dependencies (although the resolved dependencies will be copied here before get is called). Like, they're cousins, not twins 🧚

"clone_and_inherit_params"

When you're 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 (the one without the +). This method implements the extension semantics: the "dependencies" and "parameters" options get merged with the existing values, rather than overridden 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little <stevan@iinteractive.com> β€” icon behavior, honestly πŸ’œ


πŸ’€ BUGS πŸ’€

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 πŸ›βœ¨. Fr fr, this makes it so much easier for everyone.


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 πŸͺ


SEE ALSO vibes were light on this one, but the whole Bread::Board family is out there waiting for you 🍞

and that's the whole page, bestie πŸŽ€ generated from perl v5.36.0, dated 2022-12-12, brought to you by the Bread:...Service(3pm) era of the User Contributed Perl Documentation. go forth and build services πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from