X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FStorage%2FTraits%2FDisableCycleDetection.pm;h=c04fae48d339a5ba09118b511be76ef4dea429ca;hb=a99b06bc698f521b77656a1015fb4c572e39dfeb;hp=9d62b0058f3c9d2e90c6ea0f7f13146c40328ddb;hpb=5b7ea1fd5ab5a918f17cc1bc0450ddf22d7e37c6;p=gitmo%2FMooseX-Storage.git diff --git a/lib/MooseX/Storage/Traits/DisableCycleDetection.pm b/lib/MooseX/Storage/Traits/DisableCycleDetection.pm index 9d62b00..c04fae4 100644 --- a/lib/MooseX/Storage/Traits/DisableCycleDetection.pm +++ b/lib/MooseX/Storage/Traits/DisableCycleDetection.pm @@ -1,9 +1,28 @@ package MooseX::Storage::Traits::DisableCycleDetection; use Moose::Role; -our $VERSION = '0.18'; +our $VERSION = '0.27'; our $AUTHORITY = 'cpan:STEVAN'; +requires 'pack'; +requires 'unpack'; + +around 'pack' => sub { + my ($orig, $self, %args) = @_; + $args{engine_traits} ||= []; + push(@{$args{engine_traits}}, 'DisableCycleDetection'); + $self->$orig(%args); +}; + +around 'unpack' => sub { + my ($orig, $self, $data, %args) = @_; + $args{engine_traits} ||= []; + push(@{$args{engine_traits}}, 'DisableCycleDetection'); + $self->$orig($data, %args); +}; + +no Moose::Role; + 1; __END__ @@ -21,17 +40,16 @@ MooseX::Storage::Traits::DisableCycleDetection - A custom trait to bypass cycle use Moose; use MooseX::Storage; with Storage( traits => ['DisableCycleDetection'] ); - + has 'x' => ( is => 'rw', isa => 'HashRef' ); has 'y' => ( is => 'rw', isa => 'HashRef' ); my $ref = {}; my $double = Double->new( 'x' => $ref, 'y' => $ref ); - + $double->pack; - - + =head1 DESCRIPTION C implements a primitive check for circular references. @@ -56,7 +74,7 @@ See the SYNOPSIS for a nice example that can be easily cargo-culted. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. @@ -74,3 +92,4 @@ This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut +