NAME

Context::Set::Storage::Split - Split storage of Context::Set accross different Context::Set::Storage's

MANUAL

Contexts are dispatched accross different storage according to a set of rules.

A rule should have:

- name : This is free and mandatory.
- test: A Code Ref that test a given context (see example).
- storage: Where to store the contexts that pass the test. Should be an instance of any subclass of L<Context::Set::Storage>

Rules are tested in the order of the definition, so the default one should go at the end of the list. If you don't specify a default, this storage will die if no rule matches the context you make it manage.

For example:

$users_store and $general_store are instances of L<Context::Set::Storage>

## Store the contexts unders 'users' in a special store, all the rest in a general one.
my $split_store = Context::Set::Storage::Split->new({
                                                  rules => [{
                                                             name => 'users_specific',
                                                             test => sub{ shift->is_inside('users'); },
                                                             storage => $users_store
                                                            },
                                                            {
                                                             name => 'default',
                                                             test => sub{ 1; },
                                                             storage => $general_store
                                                            }]
                                                 });

BUILDARGS

See L<Moose>

In moose, we override BUILDARGS, not new.

rule

Returns a rule by name.

Usage:

$self->rule('myrule')->...

populate_context

See super class Context::Set::Storage

set_context_property

See superclass Context::Set::Storage

delete_context_property

See superclass Context::Set::Storage