The struct-iteration method is ok, and if you're building a pure web app it might be sufficient. But I do alot of API building, which is basically data fetching and serialization. I don't want to have to iterate the attributes and build my own XML/JSON. I also want to be able to point to a DB-level view for queries, since this is very useful for aggregating data and minimizing queries.
What I really want, and ActiveRecord gives pretty cleanly, is: 1) Select records/aggregates from arbitrary DB queries/views 2) Easiliy serialize to JSON and XML For example, a common pattern I use all the time is: @league_players = LeaguePlayer.find(:all, :from => 'v_league_players_extended') @league_players.to_json @league_players.to_xml I experimented with DM and tried something like this: @league_players = LeaguePlayer.all(:repository => repository (:league_players_view)) @league_players.to_json @league_players.to_xml But this required that I DM.setup an adapter for :league_players_view and do a couple other things that felt like I was doing the wrong thing. If DM offered something like the ability to specify the storage to use, and just to get readonly attributes (they don't have to be DM objects at all), it would be a huge help: @league_players = LeaguePlayer.all(:storage => 'v_league_players_extended') @league_players.to_json @league_players.to_xml -Nate --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
