From: Arthur Axel "fREW" Schmidt Date: Thu, 15 Apr 2010 15:04:38 +0000 (+0000) Subject: initial stab at incomplete docs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=22d9e05a39b5afbac794a5af9e83b4a38f766ac4;p=dbsrgits%2FDBIx-Class-Historic.git initial stab at incomplete docs --- diff --git a/lib/DBIx/Class/FilterColumn.pm b/lib/DBIx/Class/FilterColumn.pm index 7d37414..0cfcdfc 100644 --- a/lib/DBIx/Class/FilterColumn.pm +++ b/lib/DBIx/Class/FilterColumn.pm @@ -102,5 +102,42 @@ sub new { return $obj; } - 1; + +=head1 THE ONE TRUE WAY + + package My::Reusable::Filter; + + sub to_pennies { $_[1] * 100 } + sub from_pennies { $_[1] / 100 } + + 1; + + package My::Schema::Result::Account; + + use strict; + use warnings; + + use base 'DBIx::Class::Core'; + + __PACKAGE->load_components('FilterColumn'); + + __PACKAGE__->add_columns( + id => { + data_type => 'int', + is_auto_increment => 1, + }, + total_money => { + data_type => 'int', + }, + ); + + __PACKAGE__->set_primary_key('id'); + + __PACKAGE__->filter_column(total_money => { + filter_to_storage => 'to_pennies', + filter_from_storage => 'from_pennies', + }); + + 1; +