Bread:...erized(3pm)

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

πŸ’– Bread:...erized(3pm) πŸ’–

okay so bestie, welcome to the User Contributed Perl Documentation section, and this particular page is all about Bread::Board::Container::Parameterized β€” a parameterized container, no cap 🫢


✨ NAME ✨

Bread::Board::Container::Parameterized β€” a parameterized container πŸ’…


🌸 VERSION 🌸

version 0.37 β€” yeah she's on 0.37, iconic, we love a numbered queen ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So basically this class implements a sort of container factory for Bread::Board, which is giving very much "build me a thing that builds things" energy πŸ‘‘

A parameterized container is, in practice, a function from a set of parameters (and those parameters must be containers, periodt) to an actual container πŸ’«

If you want to see this in action, go look at Bread::Board::Manual::Example::FormSensible β€” there's an example there fr fr πŸ™Œ


πŸŽ€ ATTRIBUTES πŸŽ€

name

Read/write string, required. Every container needs a name, because that's how you reference it when you're fetching it 🏷️ Like, she needs a name to be called, obviously πŸ’…

allowed_parameter_names

Read-only arrayref of strings, required. These are the names of the containers that must be passed to create to actually get a real container out of this parameterized object β€” no substitutions, no extras, we're strict here bestie πŸ“‹βœ¨

container

This attribute holds the "prototype" container 🧚 Services inside it can depend on service paths that include the container names given in allowed_parameter_names 🌈


πŸ’… METHODS πŸ’…

add_service, get_service, has_service, get_service_list, has_services, add_sub_container, get_sub_container, has_sub_container, get_sub_container_list, has_sub_containers

All these methods are delegated to the prototype container, so that this object can be defined as if it were a normal container 😌 The way that delegation just makes everything work is so satisfying, honestly 🫢

create

my $container = $parameterized_container->create(%params);

After checking that the keys of %params are exactly the same strings that are present in allowed_parameter_names, this method:

  1. clones the prototype container 🧬
  2. adds the %params to the clone as sub-containers
  3. returns the clone 🎁

If this was not a top-level container, the parent is also cloned, and the container clone gets added to the parent clone β€” the whole family tree gets duplicated, lowkey dramatic but it's what she does πŸŒ³πŸ’«

⚠️ Please note, bestie: the container returned by this method does not have the same name as the parameterized container. And calling this method with different parameter values will return different containers β€” but all with the same name. It's probably a bad idea to instantiate a non-top-level parameterized container more than once. Like, don't do it. I'm serious πŸ˜­πŸ’€

fetch, resolve

These two methods die πŸ’€ because services in a parameterized container won't usually resolve, and attempting to do so is almost always a mistake πŸ™ˆ So like, don't try it, she will end you, respectfully πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little <stevan@iinteractive.com> β€” thank you for your service, king 🫑✨


πŸ› 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 πŸ™ Like, help them help you, bestie, it's giving teamwork 🌈


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 ✨ β€” yeah she's free, she's open, she's generous, we stan πŸ’–


and that's the whole page bestie!! 🌟 this doc came to you courtesy of perl v5.36.0 and it was dated 2022-12-12, mwah, bye!! πŸ’‹πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from