| Buffer-Transactional documentation | Contained in the Buffer-Transactional distribution. |
Buffer::Transactional::Buffer::Lazy - A lazy buffer using code refs
This buffer accepts CodeRefs instead of strings and will hold onto them only executing them at the very last moment when the top level transaction is commited.
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.
Stevan Little <stevan.little@iinteractive.com>
Copyright 2009, 2010 Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Buffer-Transactional documentation | Contained in the Buffer-Transactional distribution. |
package Buffer::Transactional::Buffer::Lazy; use Moose; our $VERSION = '0.02'; our $AUTHORITY = 'cpan:STEVAN'; has '_buffer' => ( traits => [ 'Array' ], is => 'rw', isa => 'ArrayRef[CodeRef]', lazy => 1, default => sub { [] }, handles => { 'put' => 'push', '_flatten' => [ 'map' => sub { $_->() } ], } ); # *sigh* Moose with 'Buffer::Transactional::Buffer'; sub subsume { my ($self, $buffer) = @_; $self->put( sub { $buffer->_flatten } ); } sub as_string { join "" => (shift)->_flatten } __PACKAGE__->meta->make_immutable; no Moose; 1; __END__