Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Lightweight DI container
Perl
branch: master

Fixed README

latest commit 818b3dbb83
@vti authored
Failed to load latest commit information.
lib Made object registration more strict
t Made object registration more strict
xt They forced me
Makefile.PL They forced me
README.pod Fixed README

README.pod

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.

Something went wrong with that request. Please try again.