Bread:...ection(3pm)

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

πŸ’– NAME πŸ’–

Bread::Board::ConstructorInjection β€” the service that makes objects by yelling at a constructor. it's giving "i don't build the thing, i just call the thing that builds the thing." ✨

so this is a Perl module, manual section 3pm, and it lives in the User Contributed Perl Documentation corner of the world. welcome bestie, come sit with me 🫢


🌸 VERSION 🌸

version 0.37 β€” that's the one, no cap πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

okay so real talk: this service class instantiates objects by calling the constructor on a class. that's literally the whole job. you hand it a class, it calls the constructor, boom, you have an object. iconic behavior honestly πŸ‘‘

and the way it does this? it consumes these three roles, like it's wearing three absolutely essential accessories:

  • Bread::Board::Service::WithClass
  • Bread::Board::Service::WithParameters
  • Bread::Board::Service::WithDependencies

all three. every time. it's a whole look and it's not negotiable πŸ’–


✨ ATTRIBUTES ✨

πŸ’œ class

this attribute is provided by Bread::Board::Service::WithClass, but here's the tea: this service makes it a required attribute.

like, obviously?? you can't call a constructor if you don't have a class. that's not a vibe, that's just physics. so if you're out here trying to run this without a class, bestie, no. 🚫

πŸ’œ constructor_name

optional string, okay? it indicates the name of the class method to invoke to construct the object. that's the whole assignment.

now β€” if you don't provide it, it defaults to the constructor name obtained via Class::MOP::Class. and if introspection does not work? it falls back to "new". so either way you're covered, she always has a backup plan πŸ¦‹


🌈 METHODS 🌈

⭐ get

this is the main character method. what it does:

  • calls the constructor (as indicated by constructor_name) on the class
  • passes all the service parameters as a hash
  • returns whatever the constructor returned

and listen, the "hopefully" is doing a lot of heavy lifting there β€” the docs say it returns whatever the constructor returned, hopefully a correctly-constructed object of the right class. so like, it's gonna give you back whatever came out. if your constructor is a mess, that's between you and your constructor. not her problem πŸ’€


πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little <stevan@iinteractive.com> β€” the author, the legend, the moment 🫢


πŸ’€ BUGS πŸ’€

found a bug? want a feature? please report any bugs or feature requests on the bugtracker website:

https://github.com/stevan/BreadBoard/issues

and when you submit a bug or a request, please include a test-file, or a patch to an existing test-file, that illustrates the bug or desired feature. fr fr β€” a repro is the love language of maintainers πŸ’–


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 ✨


lowkey this page came from perl v5.36.0, dated 2022-12-12. that's the version and the date, and that's the sign-off β€” stay hydrated, read your docs, and go construct something beautiful πŸŽ€πŸ¦‹πŸ’–
πŸ“¦ where this page comes from