Gugod, > Hi, All > > I've been very frustrated to write something like: > > my $m = Jifty->app_class(Model => "Foo")->new > $m->load($id) > > Just to load a record, so I've come up with a Jifty::ModelHelpers > module that auto-generate > a method for each model and collection in the app. So you can write > this instead: > > my $m = Foo(1); > > For collections too: > > my $foos = FooCollection; > > This is equivalent of > > my $foos = Jifty->app_class(Model => "FooCollection")->new; > $foos->unlaimit; > > Foo and FooCollection are auto-generated subs. The helper code is > attached. > > I would like you guys to tell me if something like this should be in > core. I'll make a release of such helper on my own > if not :)
IIRC you previously had a hack M("Foo") which gives you the foo model, maybe we can do something like M("Foo", Load => 1) and M("Foo", LoadByCols => foo => 'abc', email => [EMAIL PROTECTED]') ? I'd prefer polluting the namespace in a more finite and deterministic way, rather than having all models generating toplevel package. so maybe M() for model helper and MC() for collection helper? I guess that would help a lot for plugin writers as well. Cheers, CLK _______________________________________________ jifty-devel mailing list jifty-devel@lists.jifty.org http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel