On Thu, Dec 09, 2010 at 05:02:00PM -0800, Patrick Gannon wrote:
>
> We are working on a new Ruote storage provider for MongoDB, which has been
> working well for us.  A recent commit, however, broke our new provider:
> https://github.com/jmettraux/ruote/commit/7c17d143a8d85502bb6b537d39631c90aa87a4d7
> (consolidation
> of Ruote.is_tree? etc.)  The problem is that the updated code checks trees
> for containing instances of specific classes:
> 
> arg.collect { |e| e.class } == [ String, Hash, Array ]
> 
> The old code used is_a?, so instances of subclasses worked:
> 
> a.is_a?(Array) && a[1].is_a?(Hash) && a.size == 3
> 
> Our storage provider uses the Ruby Mongo driver, which returns hashes as
> instances of BSON::OrderedHash (which is a subclass of Hash), so the old
> code worked for us, and the new code doesn't. Here are two possible
> replacement expressions that test all 3 elements of the array (like the new
> code), but work with subclasses (like the old code):
> 
> 1. arg.size == 3 && [[String, Hash, Array], arg].transpose.reject {|pair|
> pair[0] === pair[1]} == []
> 
> 2. arg.size == 3 && arg[0].is_a?(String) && arg[1].is_a?(Hash) &&
> arg[2].is_a?(Array)

Hello Patrick,

I went for your second solution :

  
https://github.com/jmettraux/ruote/commit/d3a65b6787938e37d991dbad42358162f2cf197d

Many thanks !

By the way. How is the performance of ruote-mongodb compared to the fs 
persistence or the in-memory persistence ?

May I add a link to your work on the ruote website ?


Best regards,

-- 
John Mettraux - http://jmettraux.wordpress.com

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to