NAME

FlatFile::DataStore::Record - Perl module that implements a flatfile datastore record class.

SYNOPSYS

 # first, create a preamble object

 use FlatFile::DataStore::Preamble;

 my $preamble = FlatFile::DataStore::Preamble->new( {
     datastore => $ds,         # FlatFile::DataStore object
     indicator => $indicator,  # single-character crud flag
     transind  => $transind,   # single-character crud flag
     date      => $date,       # pre-formatted date
     transnum  => $transint,   # transaction number (integer)
     keynum    => $keynum,     # record sequence number (integer)
     reclen    => $reclen,     # record length (integer)
     thisfnum  => $fnum,       # file number (in base format)
     thisseek  => $datapos,    # seek position (integer)
     prevfnum  => $prevfnum,   # ditto these ...
     prevseek  => $prevseek,
     nextfnum  => $nextfnum,
     nextseek  => $nextseek,
     user      => $user_data,  # pre-formatted user-defined data
     } );

 # then create a record object with the preamble contained in it

 use FlatFile::DataStore::Record;

 my $record = FlatFile::DataStore::Record->new( {
     preamble => $preamble,                 # i.e., a preamble object
     data     => "This is a test record.",  # actual record data
     } );

DESCRIPTION

FlatFile::DataStore::Record is a Perl module that implements a flatfile datastore record class. This class defines objects used by FlatFile::DataStore. You will likely not ever call new() yourself, (FlatFile::DataStore::create() would, e.g., do that) but you will likely call the accessors.

VERSION

FlatFile::DataStore::Record version 1.03

CLASS METHODS

FlatFile::DataStore::Record->new( $parms )

Constructs a new FlatFile::DataStore::Record object.

The parm $parms is a hash reference containing key/value pairs to populate the record string. Two keys are recognized:

 - preamble, i.e., a FlatFile::DataStore::Preamble object
 - data,     the actual record data

The record data is stored in the object as a scalar reference, and new() will accept a scalar ref, e.g.,

 my $record_data = "This is a test record.";
 my $record = FlatFile::DataStore::Record->new( {
     preamble => $preamble_obj,
     data     => \$record_data,
     } );

OBJECT METHODS: Accessors

The following read/write methods set and return their respective attribute values if $value is given. Otherwise, they just return the value.

The value parameter to data() and dataref() may be a scalar or scalar ref. The return value of data() is always the scalar value. The return value of dataref() is always the scalar ref.

The value given to dataref() should be a scalar ref, and dataref() will always return a scalar ref.

    $record->data(     $value );
    $record->dataref(  $value );

    $record->preamble( $value ); # FlatFile::DataStore::Preamble object

The following read-only methods just return their respective values. The values all come from the record's contained preamble object.

 $record->user()
 $record->preamble_string()  # the 'string' attr of the preamble
 $record->indicator()
 $record->transind()
 $record->date()
 $record->transnum()
 $record->keynum()
 $record->reclen()
 $record->thisfnum()
 $record->thisseek()
 $record->prevfnum()
 $record->prevseek()
 $record->nextfnum()
 $record->nextseek()

 $record->is_created()
 $record->is_updated()
 $record->is_deleted()

AUTHOR

Brad Baxter, <bbaxter@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2011 by Brad Baxter

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.