I don't know much about the Identity map so I can't really comment on what's better. I'd just do whatever way works, and if you run into speed issues down the line, you can work on refactoring code then. That's the whole point of agile development. There are tools like perftools to track the amount of resources the certain commands of your app are using.
Quoting Yuri <[email protected]>: > On Aug 31, 3:56 pm, [email protected] wrote: > > I could be wrong again. But a simple solution that I would use for this > issue > > would be: > > > > def the_same(var1, var2) > > if var1 == var2 > > end > > > > then on any of your calls you'd just have to put: > > if !the_same(session[:my_id], params['id']) > > #if not the same > > else > > #code if the same > > end > > That would certainly work, the trouble would be the massive, obscure > crosscut. Which got me to thinking about embedding your idea in the > getter for the association, which then led to me wonder... well what > if... > > def Post > belongs_to :author, model: 'Person', required: false > > def author > Person.get(attribute_get(:author_id)) > end > end > > And, that actually prevents additional selects, presumably Model.get > is grabbing the instance the from the IdentityMap while the original > belongs_to method is hard-wired to hit the DB? > > -- > 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. > > -- 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.
