Version 0.999001
DBIx::Class::ResultSet::WithMetaData
package MyApp::Schema::ResultSet::ObjectType; use Moose; use MooseX::Method::Signatures; extends 'DBIx::Class::ResultSet::WithMetaData; method with_substr () { foreach my $row ($self->all) { my $substr = substr($row->name, 0, 3); $self->add_row_info(row => $row, info => { substr => $substr }); } return $self; } ... # then somewhere else my $object_type_arrayref = $object_type_rs->limit(count => 3)->with_substr->display(); # [{ # 'artistid' => '1', # 'name' => 'Caterwauler McCrae', # 'substr' => 'Cat' # }, # { # 'artistid' => '2', # 'name' => 'Random Boy Band', # 'substr' => 'Ran' # }, # { # 'artistid' => '3', # 'name' => 'We Are Goth', # 'substr' => 'We ' # }]
Attach metadata to rows by chaining ResultSet methods together. When the ResultSet is flattened to an ArrayRef the attached metadata is merged with the row hashes to give a combined 'hash-plus-other-stuff' representation.
$arrayref_of_row_hashrefs = $rs->display();
This method uses DBIx::Class::ResultClass::HashRefInflator to convert all rows in the ResultSet to HashRefs. These are then merged with any metadata that had been attached to the rows using "add_row_info".
$rs = $rs->add_row_info(row => $row, info => { dates => [qw/mon weds fri/] } );
This method allows you to attach a HashRef of metadata to a row which will be merged with that row when the ResultSet is flattened to a datastructure with "display".
$ordered_rs = $rs->order_by(col => 'name');
Convenience method. Essentually a shortcut for $rs->search({}, { order_by => $col }).
$limitted_rs = $rs->limit(count => 3);
Convenience method. Essentually a shortcut for $rs->search({}, { rows => $count }).
Luke Saunders <luke.saunders@gmail.com>
As usual, thanks to Matt S Trout for the sanity check.
This library is free software under the same license as perl itself
To install DBIx::Class::ResultSet::WithMetaData, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::ResultSet::WithMetaData
CPAN shell
perl -MCPAN -e shell install DBIx::Class::ResultSet::WithMetaData
For more information on module installation, please visit the detailed CPAN module installation guide.