loobmedia - webdevelopment
2007-Jan-10 08:42 UTC
[Betternestedset-talk] Fabien Franzen''s enhancements
Hi, Thanks for the pointers, Krishna. I''m looking forward to the other''s opinions as well.> The new find and count methods look great, and ought to be quite > useful (e.g. trac ticket 18). > > The methods #recurse_result_set, #result_to_array and #result_to_xml > all look fine to me, though I''m not the person to ask. JCM-- do you > have input on these methods, based on your work with the helper?I''ve implemented these methods as follows: - starting with the first node available, gather al of it''s siblings - this way each level is established - in the final iteration, any stray nodes are gathered in case of disjointed result sets I''ve spent a great deal of time on this, looking for better ways to accomplish it, but sofar the solution above seems to work best.> > I like the new sibling query methods (#next_sibling and friends), but > I''m wondering if we should use the same method names as acts_as_list, > to maintain interchangeability.If all is well, I provided aliases wherever desired to keep interchangeability. Maybe we should just switch to the aliased names instead?> Should #move_to_top and #move_to_bottom use #swap? It seems that this > will cause unexpected reordering. If we had nodes (a, b, c, d) and we > called a.move_to_bottom, the order would be (d, b, c, a) instead of > the expected (for me at least) (b, c, d, a).I stand corrected at this one indeed. Good catch. I''ll look into it.> Which brings us to the #swap method itself-- all of the new sibling > reordering methods could be accomplished with existing move_to > methods, so I''m wondering how much of a need for #swap there is. (I > recognize that #swap offers performance benefits if you do need to > swap two distant nodes.) If we decide to keep it, I think the update > statements for #swap and #move_to are equivalent, and could be handled > by a single method.Valid points as well. I do think #swap in itself is quite useful when moving two distant nodes, since you probably can''t know when to use #move_to_left_of or #move_to_right_of in that case. AFAIK you would have to check the previous sibling and the next sibling also if the former is nil. I will change the sibling reordering implementation to move_to_methods. Expect a new patch soon! - Fabien -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20070110/aed0888e/attachment.html