make spelling tests pass
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / Traits / DisableCycleDetection.pm
CommitLineData
5b7ea1fd 1package MooseX::Storage::Traits::DisableCycleDetection;
2use Moose::Role;
3
59abaf70 4requires 'pack';
5requires 'unpack';
6
7around 'pack' => sub {
8 my ($orig, $self, %args) = @_;
9 $args{engine_traits} ||= [];
10 push(@{$args{engine_traits}}, 'DisableCycleDetection');
11 $self->$orig(%args);
12};
13
14around 'unpack' => sub {
15 my ($orig, $self, $data, %args) = @_;
16 $args{engine_traits} ||= [];
17 push(@{$args{engine_traits}}, 'DisableCycleDetection');
18 $self->$orig($data, %args);
19};
20
f82612bc 21no Moose::Role;
22
5b7ea1fd 231;
24
25__END__
26
27=pod
28
29=head1 NAME
30
31MooseX::Storage::Traits::DisableCycleDetection - A custom trait to bypass cycle detection
32
33=head1 SYNOPSIS
34
35
36 package Double;
37 use Moose;
38 use MooseX::Storage;
39 with Storage( traits => ['DisableCycleDetection'] );
ec725183 40
5b7ea1fd 41 has 'x' => ( is => 'rw', isa => 'HashRef' );
42 has 'y' => ( is => 'rw', isa => 'HashRef' );
43
44 my $ref = {};
45
46 my $double = Double->new( 'x' => $ref, 'y' => $ref );
ec725183 47
5b7ea1fd 48 $double->pack;
ec725183 49
5b7ea1fd 50=head1 DESCRIPTION
51
52C<MooseX::Storage> implements a primitive check for circular references.
53This check also triggers on simple cases as shown in the Synopsis.
54Providing the C<DisableCycleDetection> traits disables checks for any cyclical
55references, so if you know what you are doing, you can bypass this check.
56
57This trait is applied to all objects that inherit from it. To use this
58on a per-case basis, see C<disable_cycle_check> in L<MooseX::Storage::Basic>.
59
8af2c2b0 60=for stopwords culted
61
5b7ea1fd 62See the SYNOPSIS for a nice example that can be easily cargo-culted.
63
64=head1 METHODS
65
66=head2 Introspection
67
68=over 4
69
70=item B<meta>
71
72=back
73
74=head1 BUGS
75
ec725183 76All complex software has bugs lurking in it, and this module is no
5b7ea1fd 77exception. If you find a bug please either email me, or add the bug
78to cpan-RT.
79
80=head1 AUTHOR
81
82Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
83
84=head1 COPYRIGHT AND LICENSE
85
86Copyright 2007-2008 by Infinity Interactive, Inc.
87
88L<http://www.iinteractive.com>
89
90This library is free software; you can redistribute it and/or modify
91it under the same terms as Perl itself.
92
93=cut
ec725183 94