| 1 | package Catalyst::Plugin::Data::Pensieve; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Data::Pensieve; | ||
| 7 | |||
| 8 | our $VERSION = 0.01; | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Catalyst::Plugin::Data::Pensieve - Easy access to Data::Pensieve within Catalyst applications | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | use Catalyst qw/ | ||
| 17 | Data::Pensieve | ||
| 18 | /; | ||
| 19 | |||
| 20 | __PACKAGE__->config( | ||
| 21 | 'Plugin::Data::Pensieve' => { | ||
| 22 | revision_model => 'DB::Revision', | ||
| 23 | revision_data_model => 'DB::RevisionData', | ||
| 24 | definitions => { | ||
| 25 | foo => [ qw/ foo_id name bar baz / ], | ||
| 26 | }, | ||
| 27 | }, | ||
| 28 | ); | ||
| 29 | |||
| 30 | sub update_data :Local :Args(3) { | ||
| 31 | my ($self, $c, $pk, $key, $value) = @_; | ||
| 32 | |||
| 33 | $c->pensieve->store_revisions( | ||
| 34 | some_kinda_data => $pk, { | ||
| 35 | $key => $value | ||
| 36 | } | ||
| 37 | ); | ||
| 38 | } | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | sub pensieve | ||
| 43 | { | ||
| 44 | my ($c) = @_; | ||
| 45 | |||
| 46 | my $config = $c->config->{'Plugin::Data::Pensieve'} || {}; | ||
| 47 | |||
| 48 | return Data::Pensieve->new( | ||
| 49 | revision_rs => scalar $c->model( $config->{revision_model} )->search, | ||
| 50 | revision_data_rs => scalar $c->model( $config->{revision_data_model} )->search, | ||
| 51 | definitions => $config->{definitions}, | ||
| 52 | ); | ||
| 53 | } | ||
| 54 | |||
| 55 | =head1 AUTHOR | ||
| 56 | |||
| 57 | Michael Aquilina <aquilina@cpan.org> | ||
| 58 | |||
| 59 | Developed for Grant Street Group's Testafy <http://testafy.com> | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | 1; | ||
| 64 | |||
| 65 |