|
NAMEMooseX::IOC - Moose attributes with IOC integrationSYNOPSIS# in a startup script somewhere ... use IOC; use IOC::Service::Parameterized; use IOC::Registry; use MooseX::IOC; { my $container = IOC::Container->new('MyProject'); $container->register(IOC::Service::Literal->new('log_file' => "logfile.log")); $container->register(IOC::Service->new('FileLogger' => sub { my $c = shift; return FileLogger->new($c->get('log_file')); })); my $reg = IOC::Registry->new; $reg->registerContainer($container); } # in a .pm file somewhere ... package MyApplication; use Moose; has 'logger' => ( metaclass => 'IOC', is => 'ro', isa => 'FileLogger', service => '/MyProject/FileLogger', ); # in a script file somewhere ... my $app = MyApplication->new; $app->logger; # automatically gotten from IOC DESCRIPTIONThis module provides a bridge between IOC registries and Moose objects through a custom attribute metaclass. It compliments the "default" option with a "service" option which contains a IOC::Registry path (and optional parameters).The "service" option can be in one of the following formats:
If the "service" is not found and a "default" option has been set, then it will return the value in "default". This can be useful for writing code which can potentially be run both under IOC and not under IOC. METHODS
SEE ALSO
BUGSAll complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.AUTHORStevan Little <stevan@iinteractive.com>COPYRIGHT AND LICENSECopyright 2007-2009 by Infinity Interactive, Inc.<http://www.iinteractive.com> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |