Mojolicious::Services - Mojolicious::Services 是为Mojolicious框架提供的Service管理插件。
use Mojolicious::services my $service_manage = Mojolicious::services->new({ dbi=>DBIx::Custom->new(), models=>{}, namespaces=>s["Mojolicious::Service"], lazy => 1 }); ## fetch a service my $user_service = $service_manage->service("user");
Mojolicious::services是为Mojolicious框架提供Service支持的模块。
Mojolicious::services 从 Mojolicious::Service中继承了所有属性,并实现以下属性。
存储service的属性。
namespaces 用于说明service类所在的命名空间,这个属性的值是一个arrayref 类型的值,支持在多个命名空间中查找service。
用于说明是否启用懒加载模式。 如果值为true则启用懒加载,只有在实际请求一个service时才加载其类并实例化一个service对象。 如果为flase则在创建Mojolicious::services时加载所有service类并实例化成对象。
Mojolicious::services 从 Mojolicious::Service中继承了所有方法,并实现以下方法。
根据service的名字加载service。
加载 namespaces 属性指定的所有命名空间下的所有service,并实例化。 注:只有在非懒加载模式的初始化阶段才会调用这个方法。
生成一个新的Mojolicious::services对象。
根据 service 的名称从 services 属性中获取 service。如果在 services 属性中不存在对应的键,则尝试从 namespaces 属性指定的命名空间中加载并实例化一个service。如果尝试加载后仍获取失败,则返回 undef。
wfso, <461663376@qq.com>
<461663376@qq.com>
Please report any bugs or feature requests to bug-mojolicious-services at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-services. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-mojolicious-services at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Mojolicious::services
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mojolicious-services
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Mojolicious-services
CPAN Ratings
http://cpanratings.perl.org/d/Mojolicious-services
Search CPAN
http://search.cpan.org/dist/Mojolicious-services/
To install Mojolicious::Services, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Services
CPAN shell
perl -MCPAN -e shell install Mojolicious::Services
For more information on module installation, please visit the detailed CPAN module installation guide.