From: t0m Date: Wed, 24 Jun 2009 21:36:53 +0000 (+0100) Subject: Ok, so, the interface just changed, and the docs are complete crap now, but the imple... X-Git-Tag: 0.20~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3513de05de63c95635c9af8a5b05261f7fabc44d;p=gitmo%2FMooseX-Storage.git Ok, so, the interface just changed, and the docs are complete crap now, but the implementation of cycle check disabling is out in the role, which is what I was going for --- diff --git a/lib/MooseX/Storage/Engine.pm b/lib/MooseX/Storage/Engine.pm index 7df03a1..729f6d9 100644 --- a/lib/MooseX/Storage/Engine.pm +++ b/lib/MooseX/Storage/Engine.pm @@ -78,13 +78,8 @@ sub collapse_attribute_value { # this might not be enough, we might # need to make it possible for the # cycle checker to return the value - # Check cycles unless explicitly disabled - if( ref $value and not( - $options->{disable_cycle_check} or - $self->object->does('MooseX::Storage::Traits::DisableCycleDetection') - )) { - $self->check_for_cycle_in_collapse($attr, $value) - } + $self->check_for_cycle_in_collapse($attr, $value) + if ref $value; if (defined $value && $attr->has_type_constraint) { my $type_converter = $self->find_type_handler($attr->type_constraint); diff --git a/lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm b/lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm index 717e243..b0ab38c 100644 --- a/lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm +++ b/lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm @@ -1,5 +1,11 @@ package MooseX::Storage::Engine::Trait::DisableCycleDetection; use Moose::Role; +around 'check_for_cycle_in_collapse' => sub { + my ($orig, $self, $attr, $value) = @_; + # See NOTE in MX::Storage::Engine + return $value; +}; + 1; diff --git a/t/004_w_cycles.t b/t/004_w_cycles.t index 12a4ca8..f7e60c1 100644 --- a/t/004_w_cycles.t +++ b/t/004_w_cycles.t @@ -155,7 +155,7 @@ This test demonstrates two things: " And unpacked again" ); } - my $pack = $double->pack( disable_cycle_check => 1 ); + my $pack = $double->pack( engine_traits => [qw/DisableCycleDetection/] ); ok( $pack, " Object packs when cycle check is disabled"); ok( Double->unpack( $pack ), " And unpacked again" );