Re: might_have , has_many request
[prev]
[thread]
[next]
[Date index for 2005/02/28]
--- Tony Bowden <tony-cdbitalk@xxxxx.xxx> wrote:
> On Mon, Feb 28, 2005 at 01:25:36PM -0800, Peter Speltz wrote:
> > I'd like it if might_have and has_many relationships took constraints. I've
> > patched my copies so i can use them the old way or like this:
>
> I don't understand what your constraints actually do,
For might_have they essentially allow you to:
* name the foreign key. Current version uses PK of class using might_have
if i'm not mistaken.. _FK_ is special name in constraints for PK of
calling class (IE cd->primary_column in the standard example)
* can might_have multi_keyed objects. Just Specify all keys in constraints.
* can might_have more than one of same class like in my example.
For has_many they just allow you to organize them and saves a step when
accessing a limited group. Better example may be:
Customer->has_many('dialup_accounts' => Account, { account_type => 'dialup'});
Customer->has_many('dsl_accounts') => Account, {account_type => 'dsl' });
This really isn't that much of a big deal especially for display cause you can
limit when you access but for automating things it
could be nice to have the extra meta info stored.
> but feel free to
> create your own Relationship classes and throw up on CPAN. Then people
> can just declare that they want has_many / might_have to use your versions
> rather than the built-ins if they want this behaviour.
>
That's good idea. Any suggestions for names as they do just the same thing.
can_have , has_many_constr ?
> If you need anything in the default Relationships facotred out better to
> make it easier to subclass them, just shout.
>
It would be nice to have a standard interface to pass args to all relationships
that will get remapped into the args slot of meta_info. This way people can add
custom meta info, like a flag or something without having to remap the args ,
which as far as i know means writing a new relationship.
has_many expects args already and so does has_a.
might_have doesn't. it slurps all args into the import array.
=====
pjs
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|
(message missing)
|