X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FStorage%2FEngine.pm;h=ec96c707c7a318aa94ad37aaf8b37fcfd00f7ec9;hb=45d9a73cb319d9cd4d3e30d07526d72cb3e11ad2;hp=558fb646f4ea3c512028a76cc311b6a9a76edd9a;hpb=7eb5dc635e43005020528128b012527cb5707559;p=gitmo%2FMooseX-Storage.git diff --git a/lib/MooseX/Storage/Engine.pm b/lib/MooseX/Storage/Engine.pm index 558fb64..ec96c70 100644 --- a/lib/MooseX/Storage/Engine.pm +++ b/lib/MooseX/Storage/Engine.pm @@ -2,7 +2,7 @@ package MooseX::Storage::Engine; use Moose; -our $VERSION = '0.01'; +our $VERSION = '0.02'; # the class marker when # serializing an object. @@ -64,7 +64,11 @@ sub collapse_attribute_value { my ($self, $attr) = @_; my $value = $attr->get_value($self->object); - $self->check_for_cycle_in_collapse($value) + # NOTE: + # this might not be enough, we might + # need to make it possible for the + # cycle checker to return the value + $self->check_for_cycle_in_collapse($attr, $value) if ref $value; if (defined $value && $attr->has_type_constraint) { @@ -79,7 +83,9 @@ sub collapse_attribute_value { sub expand_attribute_value { my ($self, $attr, $value) = @_; - $self->check_for_cycle_in_expansion($value) + # NOTE: + # (see comment in method above ^^) + $self->check_for_cycle_in_expansion($attr, $value) if ref $value; if (defined $value && $attr->has_type_constraint) { @@ -89,26 +95,40 @@ sub expand_attribute_value { return $value; } -# util methods ... +# NOTE: +# possibly these two methods will +# be used by a cycle supporting +# engine. However, I am not sure +# if I can make a cycle one work +# anyway. sub check_for_cycle_in_collapse { - my ($self, $value) = @_; + my ($self, $attr, $value) = @_; (!exists $self->seen->{$value}) - || confess "Basic Engine does not support cycles"; + || confess "Basic Engine does not support cycles in class(" + . ($attr->associated_metaclass->name) . ").attr(" + . ($attr->name) . ") with $value"; $self->seen->{$value} = undef; } sub check_for_cycle_in_expansion { - my ($self, $value) = @_; + my ($self, $attr, $value) = @_; (!exists $self->seen->{$value}) - || confess "Basic Engine does not support cycles"; + || confess "Basic Engine does not support cycles in class(" + . ($attr->associated_metaclass->name) . ").attr(" + . ($attr->name) . ") with $value"; $self->seen->{$value} = undef; } +# util methods ... + sub map_attributes { my ($self, $method_name, @args) = @_; map { $self->$method_name($_, @args) + } grep { + # Skip our special skip attribute :) + !$_->isa('MooseX::Storage::Meta::Attribute::DoNotSerialize') } ($self->object || $self->class)->meta->compute_all_applicable_attributes; } @@ -271,12 +291,12 @@ __END__ =head1 NAME -MooseX::Storage::Engine - -=head1 SYNOPSIS +MooseX::Storage::Engine - The meta-engine to handle collapsing and expanding objects =head1 DESCRIPTION +No user serviceable parts inside. If you really want to know, read the source :) + =head1 METHODS =head2 Accessors @@ -289,6 +309,8 @@ MooseX::Storage::Engine =item B +=item B + =back =head2 API @@ -313,6 +335,10 @@ MooseX::Storage::Engine =item B +=item B + +=item B + =item B =back