[Bast-commits] r9146 - in DBIx-Class/0.08/branches/filter_column:
lib/DBIx/Class t/row
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Wed Apr 14 17:30:46 GMT 2010
Author: frew
Date: 2010-04-14 18:30:46 +0100 (Wed, 14 Apr 2010)
New Revision: 9146
Modified:
DBIx-Class/0.08/branches/filter_column/lib/DBIx/Class/FilterColumn.pm
DBIx-Class/0.08/branches/filter_column/t/row/filter_column.t
Log:
working filter column impl
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-14 15:55:14 UTC (rev 9145)
+++ DBIx-Class/0.08/branches/filter_column/lib/DBIx/Class/FilterColumn.pm 2010-04-14 17:30:46 UTC (rev 9146)
@@ -73,4 +73,32 @@
return $filtered;
}
+sub update {
+ my ($self, $attrs, @rest) = @_;
+ foreach my $key (keys %{$attrs||{}}) {
+ if ($self->has_column($key) &&
+ exists $self->column_info($key)->{_filter_info}) {
+ my $val = delete $attrs->{$key};
+ $self->set_value($key, $val);
+ $attrs->{$key} = $self->_unfiltered_column($key, $val)
+ }
+ }
+ return $self->next::method($attrs, @rest);
+}
+
+
+sub new {
+ my ($class, $attrs, @rest) = @_;
+ my $filtered;
+ foreach my $key (keys %{$attrs||{}}) {
+ if ($class->has_column($key) &&
+ exists $class->column_info($key)->{_filter_info} ) {
+ $attrs->{$key} = $class->_unfiltered_column($key, delete $attrs->{$key})
+ }
+ }
+ my $obj = $class->next::method($attrs, @rest);
+ return $obj;
+}
+
+
1;
Modified: DBIx-Class/0.08/branches/filter_column/t/row/filter_column.t
===================================================================
--- DBIx-Class/0.08/branches/filter_column/t/row/filter_column.t 2010-04-14 15:55:14 UTC (rev 9145)
+++ DBIx-Class/0.08/branches/filter_column/t/row/filter_column.t 2010-04-14 17:30:46 UTC (rev 9146)
@@ -8,8 +8,8 @@
my $schema = DBICTest->init_schema();
DBICTest::Schema::Artist->load_components('FilterColumn');
DBICTest::Schema::Artist->filter_column(rank => {
- filter => sub { warn "FILTERING!"; $_[1] * 2 },
- unfilter => sub {warn "UNFILTERING!"; $_[1] / 2 },
+ filter => sub { $_[1] * 2 },
+ unfilter => sub { $_[1] / 2 },
});
Class::C3->reinitialize();
More information about the Bast-commits
mailing list