DBIx::Class::Row::Delta - Keep track of and report on changes to a DBIC row object.
Record an initial set of values for a DBIC row, and later on get a string with the changed values.
use DBIx::Class::Row::Delta; my $book = $book_rs->find(321); my $book_notes_delta = DBIC::Row::Delta->new({ dbic_row => $book, changes_sub => sub { my ($row) = @_; return { "Book Type" => $row->book_type->type, "Book Title" => $row->book_title->title // "N/A", "Delivery Date" => $row->delivery_date->ymd, }; }, }); # ... # Do stuff to $book, ->update(), etc. # ... # Note: this will discard_changes on $book. my $changes_string = $book_notes_delta->changes; # e.g. # Book SKU (1933021-002 => 1933023-001), Delivery Date (2012-01-18 => 2012-01-22)
Create a new object. Start by taking a snapshot of the contents of $dbic_row by calling $changes_sub->($dbic_row).
The sub ref $changes_sub should return a hash ref with keys and values that describe the state of the object. If the values look weird when stringified, you're responsible for formatting them properly. All the hash ref values should be strings or undef.
Both dbic_row and changes_sub are required.
Return a string representation of the diff between the initial snapshot and the current state of $dbic_row, or return undef if they are the same. Only the changed values are reported.
Example:
Book SKU (1933021-002 => 1933023-001), Delivery Date (2012-01-18 => 2012-01-22)
Note: This will start by calling $dbic_row->discard to refresh the data properly.
Please report any bugs or feature requests to bug-dbix-class-row-delta at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-Row-Delta. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-dbix-class-row-delta at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc DBIx::Class::Row::Delta
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-Row-Delta
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/DBIx-Class-Row-Delta
CPAN Ratings
http://cpanratings.perl.org/d/DBIx-Class-Row-Delta
Search CPAN
http://search.cpan.org/dist/DBIx-Class-Row-Delta/
The source for this module is on GitHub: https://github.com/jplindstrom/p5-DBIx-Class-Row-Delta
Patches welcome, etc.
Johan Lindstrom - johanl@cpan.org on behalf of Net-A-Porter - http://www.net-a-porter.com/
johanl@cpan.org
Copyright 2012- Net-A-Porter.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
Thanks to Net-A-Porter for providing time during one of the regular Hack-days.
To install DBIx::Class::Row::Delta, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::Row::Delta
CPAN shell
perl -MCPAN -e shell install DBIx::Class::Row::Delta
For more information on module installation, please visit the detailed CPAN module installation guide.