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