Scroll to navigation

Bread::Board::LifeCycle::Singleton::WithParameters(3pm) User Contributed Perl Documentation Bread::Board::LifeCycle::Singleton::WithParameters(3pm)

NAME

Bread::Board::LifeCycle::Singleton::WithParameters - singleton lifecycle role for a parameterized service

VERSION

version 0.37

DESCRIPTION

Sub-role of Bread::Board::LifeCycle, this role defines the "singleton" lifecycle for a parameterized service. The "get" method will only do its work the first time it is invoked for each set of parameters; subsequent invocations with the same parameters will return the same object.

ATTRIBUTES

"instances"

Hashref mapping keys to objects, used to cache the results of "get"

METHODS

"get"

Generates a key using "generate_instance_key" (passing it all the arguments); if the "instances" attribute does not hold an object for that key, it will build it (by calling the underlying "get" method) and store it in "instances". The object (either retrieved from "instances" or freshly built) will be returned.

"generate_instance_key"

Generates a (hopefully) unique key from the given arguments (usually, whatever was passed to "get"). The current implementation stringifies all arguments, so different references to identical values will be considered different.

AUTHOR

Stevan Little <stevan@iinteractive.com>

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.

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.

2022-12-12 perl v5.36.0