package Table::Denormalized::Row; use strict; use base 'Class::Accessor'; =head1 NAME Table::Denormalized::Row - Row-based DB interaction =head1 SYNOPSIS package My::Row; use base 'Table::Denormalized::Row'; my $results = $idx->query({ artist => 'Jamiroquai' }); $_->delete for @$results; =head1 ABSTRACT This module provides four (trivial) methods for every row, in a Class::DBI-style manner. It requires some magic entries in the hash (until these get moved into inside-out objects) : _id - the primary key of the table _table - a reference to the corresponding Table::Denormalized object =head2 C<< $row->delete >> Removes the row from the database =cut sub delete { my ($self) = @_; $self->{_table}->delete($self->{_id}); }; =head2 C<< $row->update >> Writes the body of the row into the database =cut sub update { my ($self) = @_; $self->{_table}->update($self); }; =head2 C<< $row->_skeleton >> Returns the skeleton of the row, that is, all keys that match C. This is convenient when copying or cloning a row. =cut sub _skeleton { my ($self) = @_; map { /^_/ ? ($_ => $self->{$_}) : () } keys %$self }; =head2 C<< $row->_body >> Returns the body of the row, that is, all keys that do not match C. This is convenient when copying or cloning a row. =cut sub _body { my ($self) = @_; map { ! /^_/ ? ($_ => $self->{$_}) : () } keys %$self }; 1; =head1 AUTHOR Max Maischein, Ecorion@cpan.orgE =head1 SEE ALSO L, L