Bread:...gleton(3pm)

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

πŸ’– Bread::Board::LifeCycle::Singleton πŸ’–

okay bestie so this is a page from the User Contributed Perl Documentation and it's literally about a tiny little role called Bread::Board::LifeCycle::Singleton β€” say that five times fast, I dare you 🫢


✨ NAME ✨

Bread::Board::LifeCycle::Singleton β€” it's the service role for singleton lifecycle. that's the whole vibe. one job, does it flawlessly, queen behavior πŸ‘‘


🌸 VERSION 🌸

this is version 0.37 πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so this role is a sub-role of Bread::Board::LifeCycle (yes it has a parent, we love a family tree), and what it does is define the "singleton" lifecycle for a service.

and what does singleton mean, you ask? it means the get method will only do its actual work the first time it's invoked. every single time after that? subsequent invocations just hand you back the same object. same one. identical. it's giving "I already did this, I'm not doing it again" and honestly? relatable 😭✨


πŸŽ€ ATTRIBUTES πŸŽ€

🌈 "instance"

this is the object that got built by the last call to get that actually did any work. and it's also what gets returned by any subsequent call to get. it just sits there, being the one and only, main character energy fr fr πŸ‘‘


πŸ’… METHODS πŸ’…

⭐ "get"

the first time this gets called β€” or the first time after you call "flush_instance" β€” the actual real get method gets invoked, and its return value gets cached in the instance attribute. and then the value of that attribute is always what gets returned.

so like, call get as many times as you need, bestie. go off. you will always, always receive the same instance. no cap πŸ’–

⭐ "has_instance"

predicate for the "instance" attribute. yep that's it, it just checks if the thing exists 🫢

⭐ "flush_instance"

clearer for the "instance" attribute. and clearing the attribute will cause the next call to get to instantiate a brand new object. so like... be aware you're wiping the slate, okay? fresh start, new instance, new era ✨


πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little <stevan@iinteractive.com> β€” absolute icon, thank you for your service πŸ«‘πŸ’œ


πŸ’€ BUGS πŸ’€

found a bug? got a feature request? please please report it 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 the feature you want. like, show us the receipts, not just vibes πŸ™ˆ


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 πŸŽ€


okay that's the whole page, you made it to the end, I'm so proud of you πŸ₯Ή

and just so you have it β€” this page came from perl v5.36.0, dated 2022-12-12. byeee, go build something iconic πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from