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)

For the moment, I've created a fork using #1:
https://github.com/PatrickGannon/ruote/commit/01b08a41487ea8557ef5e1abbb6ca2de9322bcc7

What is the preferred solution to this problem?  We can submit a patch if
its helpful.

Thank you!
Pat Gannon

-- 
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