X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FStorage.pm;fp=lib%2FMooseX%2FStorage.pm;h=e74a60676d109ed94a1175e1c3d081a49cca5149;hb=76218b465af423661a8b711a20e3e458f9adbb08;hp=2686d5668983b6625e223a93c3fe76e1f6fc1169;hpb=14ef44949f62c764658d56b954bd507d88780213;p=gitmo%2FMooseX-Storage.git diff --git a/lib/MooseX/Storage.pm b/lib/MooseX/Storage.pm index 2686d56..e74a606 100644 --- a/lib/MooseX/Storage.pm +++ b/lib/MooseX/Storage.pm @@ -52,6 +52,13 @@ sub _injected_storage_role_generator { # || confess "You must specify a format role in order to use an IO role"; push @roles => 'MooseX::Storage::IO::' . $params{'io'}; } + + # Note: + # These traits alter the behaviour of the engine, the user can + # specify these per role-usage + for my $trait ( @{ $params{'traits'} ||= [] } ) { + push @roles, 'MooseX::Storage::Traits::'.$trait; + } Class::MOP::load_class($_) || die "Could not load role (" . $_ . ")" @@ -164,6 +171,27 @@ to also be used, the expection being the C role. =back +=head2 Behaviour modifiers + +The serialization behaviour can be changed by supplying C. +This can be done as follows: + + use MooseX::Storage; + with Storage( traits => [Trait1, Trait2,...] ); + +The following traits are currently bundled with C: + +=over 4 + +=item OnlyWhenBuilt + +Only attributes that have been built (ie, where the predicate returns +'true') will be serialized. This avoids any potentially expensive computations. + +See L for details. + +=back + =head2 How we serialize There are always limits to any serialization framework, there are just