From 4aded4e8dae01257d3d835251b9ae7c2d7c8a767 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 2 Sep 2010 16:31:46 +0200 Subject: [PATCH] =?utf8?q?stub=20f=C3=BCr=20einen=20generische=20attrhelpe?= =?utf8?q?r.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Object.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/SL/DB/Object.pm b/SL/DB/Object.pm index 1a39431c6..f9508507e 100644 --- a/SL/DB/Object.pm +++ b/SL/DB/Object.pm @@ -80,6 +80,22 @@ sub update_attributes { return $self; } +sub make_attr_helper { + my ($self) = @_; + my $package = ref $self || $self; + + for my $col ($package->meta->columns) { + next if $col->primary_key_position; # don't make attr helper for primary keys + + attr_number ($package, $col->name, -2) if $col->type =~ /numeric | real | float/xi; + attr_percent($package, $col->name, -2) if $col->type =~ /numeric | real | float/xi; + attr_number ($package, $col->name, 0) if $col->type =~ /int/xi; + attr_date ($package, $col->name) if $col->type =~ /date | timestamp/xi; + } + + return $self; +} + sub attr_number { SL::DB::Helpers::AttrNumber::define(@_); } -- 2.20.1