[Jifty-commit] r5967 - in JiftyX-ModelHelpers/trunk: lib/JiftyX
Jifty commits
jifty-commit at lists.jifty.org
Thu Oct 30 02:29:17 EDT 2008
Author: gugod
Date: Thu Oct 30 02:29:17 2008
New Revision: 5967
Modified:
JiftyX-ModelHelpers/trunk/ (props changed)
JiftyX-ModelHelpers/trunk/lib/JiftyX/ModelHelpers.pm
Log:
r24672 at yra: gugod | 2008-10-30 13:43:56 +0800
refactor the auto-built helpers with M().
Modified: JiftyX-ModelHelpers/trunk/lib/JiftyX/ModelHelpers.pm
==============================================================================
--- JiftyX-ModelHelpers/trunk/lib/JiftyX/ModelHelpers.pm (original)
+++ JiftyX-ModelHelpers/trunk/lib/JiftyX/ModelHelpers.pm Thu Oct 30 02:29:17 2008
@@ -45,23 +45,13 @@
if ( index($model, "Collection") >= 0) {
*{"$model"} = sub {
my @args = @_;
- my $obj = Jifty->app_class(Model => "$model")->new;
- if (@args == 0) {
- $obj->unlimit;
- }
- elsif (@args % 2 == 0) {
- my %limits = @args;
- while( my ($col, $val) = each %limits) {
- $obj->limit(column => $col, value => $val);
- }
- }
- return $obj;
+ return M($model, @args);
}
}
else {
*{"$model"} = sub {
my @args = @_;
- my $obj = Jifty->app_class(Model => "$model")->new;
+ my $obj = M($model);
if (@args == 1) {
$obj->load($args[0]);
}
@@ -195,8 +185,8 @@
use JiftyX::ModelHelpers ':auto':
The record function takes either exact one argument or a hash. When it
- is given only one argument, that argument is treated as the value of
- "id" field and the record with that id is retured. Such as:
+is given only one argument, that argument is treated as the value of
+"id" field and the record with that id is retured. Such as:
my $book = Book(42);
More information about the Jifty-commit
mailing list