[Bast-commits] r9182 -
DBIx-Class/0.08/branches/filter_column/lib/DBIx/Class
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Thu Apr 15 15:04:38 GMT 2010
Author: frew
Date: 2010-04-15 16:04:38 +0100 (Thu, 15 Apr 2010)
New Revision: 9182
Modified:
DBIx-Class/0.08/branches/filter_column/lib/DBIx/Class/FilterColumn.pm
Log:
initial stab at incomplete docs
Modified: DBIx-Class/0.08/branches/filter_column/lib/DBIx/Class/FilterColumn.pm
===================================================================
--- DBIx-Class/0.08/branches/filter_column/lib/DBIx/Class/FilterColumn.pm 2010-04-15 14:35:25 UTC (rev 9181)
+++ DBIx-Class/0.08/branches/filter_column/lib/DBIx/Class/FilterColumn.pm 2010-04-15 15:04:38 UTC (rev 9182)
@@ -102,5 +102,42 @@
return $obj;
}
+1;
-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;
+
More information about the Bast-commits
mailing list