#265 ✓resolved
Sam Smoot

Association proxies to other associations

Reported by Sam Smoot | May 8th, 2008 @ 06:32 PM

Basically because we don't return Arrays anymore,

Zoo.exhibits.map { |e| e.animals.entries }.flatten.compact

Gets kinda ugly with the .entries in there. I'd like to see a feature from DM 0.3.x make it into 0.9.x that allows you to:

Zoo.exhibits.animals

To accomplish the same.

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 8th, 2008 @ 06:39 PM

    This is exactly the sort of thing I was thinking about for the Collection to handle. Since its lazy, and I want to make it store the Query object internally (instead of just a closure around the DOA reader stuff), I think this is totally doable.

    The DM::Query::Path stuff would be created with the above example, but I don't see that as a problem long term. We could make it so Collection does double-duty as a lazy array (which it does now), and as a replacement for DM::Query::Path provided it can be introspected to figure out the :links that should be used in the Query it's passed to.

  • Sam Smoot

    Sam Smoot May 9th, 2008 @ 11:03 AM

    • Assigned user changed from “Dan Kubb (dkubb)” to “Adam French”

    Until we can discuss your plans Dan, we'll just take the easy way out for now and add a method to handle the map/flatten/compact of associations to Collection.

    Adam, PDI sir, PDI.

  • Adam French

    Adam French May 10th, 2008 @ 03:32 PM

    so we can now go one association deep

       Post.all.categories
    

    But the setup isn't optimal and iterates over #entries rather than smartly loading the associations with 1 call to the data-store.

    Still though, it's close

  • Adam French

    Adam French May 20th, 2008 @ 09:36 PM

    • State changed from “new” to “resolved”

    I guess I never marked this resolved. Here goes....

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages