Skip to content

zby/cole

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Cole - Lightweight DI container

SYNOPSIS

$ioc = Cole->new;

$ioc->register('class name', class => 'Foo');
$ioc->register('string',     'Hello, world!');
$ioc->register('instance',   Foo->new);

$ioc->register('dependency', class => 'Bar', deps => 'foo');
$ioc->register(
    'multiple dependencies',
    class => 'Baz',
    deps  => ['foo', 'bar']
);

DESCRIPTION

Cole is a lightweight Dependency Injection container.

FEATURES

Values

$ioc->register(string   => {value => 'Hello world!'});
$ioc->register(instance => {value => Foo->new});

Class names

$ioc->register(class => {class => 'Foo'});

Dependencies

$ioc->register(class => {class => 'Foo', deps => 'bar'});

Aliases

$ioc->register(bar => {class => 'Bar'});
$ioc->register(class => {class => 'Foo', deps => {bar => 'baz'}});

bar is passed as baz during Foo creation.

METHODS

new

my $ioc = Cole->new;

register

$ioc->register(name => {class => 'foo'});

Register a new dependency.

get

$ioc->get('name');

Return an instance of a service by name.

DEVELOPMENT

Repository

http://github.com/vti/cole

AUTHOR

Viacheslav Tykhanovskyi, vti@cpan.org.

COPYRIGHT AND LICENSE

Copyright (C) 2011, Viacheslav Tykhanovskyi

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

About

Lightweight DI container

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Perl 100.0%