Context::Set::Storage::Split - Split storage of Context::Set accross different Context::Set::Storage's
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 }] });
See L<Moose> In moose, we override BUILDARGS, not new.
Returns a rule by name.
Usage:
$self->rule('myrule')->...
See super class Context::Set::Storage
See superclass Context::Set::Storage
To install Context::Set, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Context::Set
CPAN shell
perl -MCPAN -e shell install Context::Set
For more information on module installation, please visit the detailed CPAN module installation guide.