NAME

Sub::Contract::Pool - A pool of all subroutine contracts

SYNOPSIS

use Sub::Contract::Pool qw(get_contract_pool);

my $pool = get_contract_pool();

# disable all contracts in package My::Test
foreach my $contract ($pool->find_contracts_matching("^My::Test::[^:]$")) {
    $contract->disable;
}

# or simply
disable_contracts_matching("^My::Test::[^:]$");

DESCRIPTION

Every subroutine contracts defined with Sub::Contract is automatically added to a pool of contracts.

You can query this pool to retrieve contracts based on the name of the contractors (ie package name + subroutine name). You can then modify, recompile, enable and disable contracts that you fetch from the pool, at any time during runtime.

Sub::Contract::Pool uses a singleton pattern, giving you access to a unique contract pool.

API

my $pool = get_contract_pool();

Return the contract pool.

new()

Pool constructor, for internal use only. DO NOT USE NEW(), always use get_contract_pool().

$pool->list_all_contracts

Return all contracts registered in the pool.

$pool->has_contract($fully_qualified_name)

Return true if the subroutine identified by $fully_qualified_name has a contract.

$pool->enable_all_contracts

Enable all the contracts registered in the pool.

$pool->disable_all_contracts

Disable all the contracts registered in the pool.

$pool->enable_contracts_matching($regexp)

Enable all the contracts registered in the pool whose contractor's fully qualified names matches the string $regexp. regexp works as for find_contracts_matching.

$pool->disable_contracts_matching($regexp)

Disable all the contracts registered in the pool whose contractor's fully qualified names matches the string $regexp. regexp works as for find_contracts_matching.

$pool->find_contracts_matching($regexp)

Find all the contracts registered in the pool and whose contractor's fully qualified names matches the string $regexp.

SEE ALSO

See 'Sub::Contract'.

VERSION

$Id: Pool.pm,v 1.8 2008/05/19 14:09:47 erwan_lemonnier Exp $

AUTHOR

Erwan Lemonnier <erwan@cpan.org>

LICENSE

See Sub::Contract.