BoutrosLab-TSVStream
view release on metacpan or search on metacpan
lib/BoutrosLab/TSVStream/IO/Role/Fixed.pm view on Meta::CPAN
package BoutrosLab::TSVStream::IO::Role::Fixed;
# safe Perl
use warnings;
use strict;
use Carp;
use Moose::Role;
use namespace::autoclean;
use Moose::Util qw(find_meta);
use BoutrosLab::TSVStream::IO::Reader::Fixed;
use BoutrosLab::TSVStream::IO::Writer::Fixed;
=head1 NAME
BoutrosLab::TSVStream::IO::Role::Fixed
=head1 SYNOPSIS
# in a Moose class definition...
use MooseX::ClassAttribute
class_has '_fields' => (
is => 'ro',
isa => 'ArrayRef',
default => sub { [qw(foo bar)] }
);
# # or, without using MooseX::ClassAttribute
# my $_fields = [ qw(foo bar) ];
# sub _fields { return $_fields }
with 'BoutrosLab::TSVStream::IO::Role::Fixed';
has 'foo' => ( ... );
has 'bar' => ( ... );
...
=head1 DESCRIPTION
This role provides methods to create a file/iostream reader/writer
for a class, using a stream of lines with tab separated fields for
each record, converting to/from an object of the class. Usually,
the stream will start with an initial line that has the field names
as a tab separated record.
This role is also provided a BUILDARGS wrapper that alows the
constructor to be given one element pair in the parameter list:
(field_values=>[val1,val2,...]) instead of providing each field
explicitly by name as (fld1=>val1, fld2=>val2, ...). In such a
case, the values in the B<field_values> array must be in the same
order as they are listed in the B<_fields> class attribute.
=cut
has [qw(_tsvinternal_pre_header _tsvinternal_pre_comments _tsvinternal_post_comments)] => (
is => 'ro',
isa => 'ArrayRef[Str]',
default => sub { [] }
);
sub _reader_class {
return 'BoutrosLab::TSVStream::IO::Reader::Fixed';
}
sub _writer_class {
return 'BoutrosLab::TSVStream::IO::Writer::Fixed';
( run in 0.621 second using v1.01-cache-2.11-cpan-39bf76dae61 )