You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by eh...@apache.org on 2007/01/16 18:50:56 UTC

svn commit: r496797 - in /incubator/solr/trunk/client/ruby/solrb: lib/solr/document.rb test/unit/document_test.rb

Author: ehatcher
Date: Tue Jan 16 09:50:55 2007
New Revision: 496797

URL: http://svn.apache.org/viewvc?view=rev&rev=496797
Log:
Allow field hash to take an array for values

Modified:
    incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb
    incubator/solr/trunk/client/ruby/solrb/test/unit/document_test.rb

Modified: incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb?view=diff&rev=496797&r1=496796&r2=496797
==============================================================================
--- incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb (original)
+++ incubator/solr/trunk/client/ruby/solrb/lib/solr/document.rb Tue Jan 16 09:50:55 2007
@@ -36,7 +36,9 @@
     def <<(fields)
       case fields
       when Hash
-        fields.each_pair {|k,v| @fields << Solr::Field.new(k => v)}
+        fields.each_pair do |name,value|
+          value.each {|v| @fields << Solr::Field.new(name => v)}
+        end
       when Solr::Field
         @fields << fields
       else

Modified: incubator/solr/trunk/client/ruby/solrb/test/unit/document_test.rb
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/client/ruby/solrb/test/unit/document_test.rb?view=diff&rev=496797&r1=496796&r2=496797
==============================================================================
--- incubator/solr/trunk/client/ruby/solrb/test/unit/document_test.rb (original)
+++ incubator/solr/trunk/client/ruby/solrb/test/unit/document_test.rb Tue Jan 16 09:50:55 2007
@@ -31,6 +31,11 @@
     assert_equal "<doc><field name='creator'>Erik Hatcher</field><field name='creator'>Otis Gospodnetic</field></doc>", doc.to_xml.to_s
   end
   
+  def test_repeatable_in_hash
+    doc = Solr::Document.new({:creator => ['Erik Hatcher', 'Otis Gospodnetic']})
+    assert_equal "<doc><field name='creator'>Erik Hatcher</field><field name='creator'>Otis Gospodnetic</field></doc>", doc.to_xml.to_s
+  end
+  
   def test_bad_doc
     doc = Solr::Document.new
     assert_raise(RuntimeError) do