initial stab at incomplete docs
Arthur Axel "fREW" Schmidt [Thu, 15 Apr 2010 15:04:38 +0000 (15:04 +0000)]
lib/DBIx/Class/FilterColumn.pm

index 7d37414..0cfcdfc 100644 (file)
@@ -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;
+