MooseX::Role::Registry
package Foo::Registry; use Moose; with 'MooseX::Role::Registry'; sub config_file { return '/foo_objects.yml'; } sub build_registry_object { my $self = shift; my $name = shift; my $values = shift || {}; return Foo->new({ name => $name, %$values }); } package main; my $registry = Foo::Registry->instance; my $foo = $registry->get('bar');
This role watches a file which describes a hashref of objects in yml format. This hashref is called a "registry" because the objects in the hashref can be requested by name using get.
Implementations should be singletons! In other words, when using a class that is derived from MooseX::Role::Registry, you shouldn't call new. Instead, just get the singelton object using the instance method and call get on the result.
Returns the filesystem path of the default location of the configuration file that is watched by a given consumer of MooseX::Role::Registry
A function to create an object of the registy entry
Returns the registered entity called $name, or undef if none exists.
Returns all of the objects stored in the registry. Useful for generic grep() calls.
Returns a list of all of the (lookup) keys of objects currently registered in $self.
A callback which allows subclasses to modify the hashref of loaded objects before they are stored in memory as part of $self.
GitHub
binary.com, <perl at binary.com>
<perl at binary.com>
Please report any bugs or feature requests to bug-moosex-role-registry at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Role-Registry. We will be notified, and then you'll automatically be notified of progress on your bug as we make changes.
bug-moosex-role-registry at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc MooseX::Role::Registry
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Role-Registry
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/MooseX-Role-Registry
CPAN Ratings
http://cpanratings.perl.org/d/MooseX-Role-Registry
Search CPAN
http://search.cpan.org/dist/MooseX-Role-Registry/
To install MooseX::Role::Registry, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Role::Registry
CPAN shell
perl -MCPAN -e shell install MooseX::Role::Registry
For more information on module installation, please visit the detailed CPAN module installation guide.