MetaStore::Cmetalinks - class for collections of data, stored in database.


MetaStore documentation Contained in the MetaStore distribution.

Index


Code Index:

NAME

Top

MetaStore::Cmetalinks - class for collections of data, stored in database.

SYNOPSIS

Top

    use MetaStore::Cmetalinks;
    my $links = new MetaStore::Cmetalinks::
      dbh   => $dbh,
      table => 'metalinks',
      field => 'lsrc';

DESCRIPTION

Top

Class for collections of data, stored in database.

METHODS

Top

SEE ALSO

Top

MetaStore, Collection::AutoSQLnotUnique,README

AUTHOR

Top

Zahatski Aliaksandr, <zag@cpan.org>

COPYRIGHT AND LICENSE

Top


MetaStore documentation Contained in the MetaStore distribution.
package  MetaStore::Cmetalinks;


use strict;
use warnings;
use Data::Dumper;
use Collection::AutoSQLnotUnique;
use Collection::AutoSQL;
our @ISA = qw(Collection::AutoSQLnotUnique);
sub after_load {
    my $self = shift;
    my %attr = ();
    foreach my $rec (@_) {
        my ($name,$val, $type ) = @{$rec}{qw/ lid ldst lex/};
            $attr{$type}{$name} = $val
    }
    while ( my ($type, $list) = each %attr) {
        $attr{$type} = [ map { $list->{$_} } sort { $a <=> $b } keys %$list ]
    }
    return \%attr;
}

sub before_save {
    my $self = shift;
    my $attr = shift;
    my @res;
    while ( my ($type, $array ) = each %$attr) {
    $array ||= [];
    my $i;
    foreach my $rec (@$array) {
            $i++;
            push @res,{ ldst=>$rec , lid=>$i, lex => $type } 
    }
    }
    return \@res
}

sub _prepare_record {
    my $self = shift;
    my ( $key, $ref ) = @_;
    return $self->Collection::AutoSQL::_prepare_record($key,$ref);
}
1;
__END__