line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Buffer::Transactional::Buffer::Lazy; |
2
|
2
|
|
|
2
|
|
5440
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
5
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has '_buffer' => ( |
8
|
|
|
|
|
|
|
traits => [ 'Array' ], |
9
|
|
|
|
|
|
|
is => 'rw', |
10
|
|
|
|
|
|
|
isa => 'ArrayRef[CodeRef]', |
11
|
|
|
|
|
|
|
lazy => 1, |
12
|
|
|
|
|
|
|
default => sub { [] }, |
13
|
|
|
|
|
|
|
handles => { |
14
|
|
|
|
|
|
|
'put' => 'push', |
15
|
|
|
|
|
|
|
'_flatten' => [ 'map' => sub { $_->() } ], |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# *sigh* Moose |
20
|
|
|
|
|
|
|
with 'Buffer::Transactional::Buffer'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub subsume { |
23
|
|
|
|
|
|
|
my ($self, $buffer) = @_; |
24
|
|
|
|
|
|
|
$self->put( sub { $buffer->_flatten } ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub as_string { |
28
|
|
|
|
|
|
|
join "" => (shift)->_flatten |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
no Moose; 1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Buffer::Transactional::Buffer::Lazy - A lazy buffer using code refs |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This buffer accepts CodeRefs instead of strings and will hold onto |
46
|
|
|
|
|
|
|
them only executing them at the very last moment when the top |
47
|
|
|
|
|
|
|
level transaction is commited. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 BUGS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
52
|
|
|
|
|
|
|
exception. If you find a bug please either email me, or add the bug |
53
|
|
|
|
|
|
|
to cpan-RT. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 AUTHOR |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Stevan Little E<lt>stevan.little@iinteractive.comE<gt> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Copyright 2009, 2010 Infinity Interactive, Inc. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
L<http://www.iinteractive.com> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
66
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |