| 1 | use warnings; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | package Jifty::DBI::Filter; | ||
| 5 | use base 'Class::Accessor::Fast'; | ||
| 6 | |||
| 7 | __PACKAGE__->mk_accessors(qw(record column value_ref)); | ||
| 8 | |||
| 9 | =head2 new | ||
| 10 | |||
| 11 | Takes | ||
| 12 | |||
| 13 | =over | ||
| 14 | |||
| 15 | =item value_ref | ||
| 16 | |||
| 17 | A reference to the current value you're going to be | ||
| 18 | massaging. C<encode> works in place, massaging whatever value_ref | ||
| 19 | refers to. | ||
| 20 | |||
| 21 | =item column | ||
| 22 | |||
| 23 | A L<Jifty::DBI::Column> object, whatever sort of column we're working | ||
| 24 | with here. | ||
| 25 | |||
| 26 | =back | ||
| 27 | |||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | sub new { | ||
| 32 | my $class = shift; | ||
| 33 | my %args = ( | ||
| 34 | column => undef, | ||
| 35 | value_ref => undef, | ||
| 36 | @_ | ||
| 37 | ); | ||
| 38 | my $self = {}; | ||
| 39 | bless $self, $class; | ||
| 40 | |||
| 41 | for ( keys %args ) { | ||
| 42 | if ( $self->can($_) ) { | ||
| 43 | $self->$_( $args{$_} ); | ||
| 44 | } | ||
| 45 | |||
| 46 | } | ||
| 47 | |||
| 48 | return ($self); | ||
| 49 | |||
| 50 | } | ||
| 51 | |||
| 52 | =head2 encode | ||
| 53 | |||
| 54 | C<encode> takes data that users are handing to us and marshals it into | ||
| 55 | a form suitable for sticking it in the database. This could be anything | ||
| 56 | from flattening a L<DateTime> object into an ISO date to making sure | ||
| 57 | that data is utf8 clean. | ||
| 58 | |||
| 59 | =cut | ||
| 60 | |||
| 61 | sub encode { | ||
| 62 | |||
| 63 | } | ||
| 64 | |||
| 65 | =head2 decode | ||
| 66 | |||
| 67 | C<decode> takes data that the database is handing back to us and gets | ||
| 68 | it into a form that's OK to hand back to the user. This could be | ||
| 69 | anything from flattening a L<DateTime> object into an ISO date to | ||
| 70 | making sure that data is utf8 clean. | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | sub decode { | ||
| 75 | |||
| 76 | } | ||
| 77 | |||
| 78 | 1; |