Object::Container::Namespace - Container with name space register
package MyApp::Container;
use strict;
use warnings;
use Object::Container::Namespace -base;
register 'db' => sub {
my $self = shift;
MyApp::DB->new;
};
package Hoge::Api::Wassr;
use strict;
use warnings;
sub new {
bless {},shift;
}
sub login { 'do something' }
package Hoge::Pages::Fuga;
use strict;
use warnings;
use MyApp::Container qw/api/;
sub dispatch_index {
my $self = shift;
#get registered object
container('db')->search();
#get registered object by namespace register
api('wassr')->login('wasao');
#call Hoge::Api::Twitter->login
api('twitter')->login('tweet');
}
Object::Container::Namespace is Container with name space register
Nishibayashi Takuji <takuji {at} senchan.jp>
Object::Container Kamui::Container
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.