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/04/26 04:09:51 UTC
svn commit: r532569 -
/lucene/solr/trunk/client/ruby/solr-ruby/lib/solr/importer/mapper.rb
Author: ehatcher
Date: Wed Apr 25 19:09:50 2007
New Revision: 532569
URL: http://svn.apache.org/viewvc?view=rev&rev=532569
Log:
Add option to stringify symbols when looking them up from an original object. An alternate approach could be to have two different classes, one for objects with symbol keys, and one for string keys
Modified:
lucene/solr/trunk/client/ruby/solr-ruby/lib/solr/importer/mapper.rb
Modified: lucene/solr/trunk/client/ruby/solr-ruby/lib/solr/importer/mapper.rb
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/ruby/solr-ruby/lib/solr/importer/mapper.rb?view=diff&rev=532569&r1=532568&r2=532569
==============================================================================
--- lucene/solr/trunk/client/ruby/solr-ruby/lib/solr/importer/mapper.rb (original)
+++ lucene/solr/trunk/client/ruby/solr-ruby/lib/solr/importer/mapper.rb Wed Apr 25 19:09:50 2007
@@ -11,8 +11,9 @@
# limitations under the License.
class Solr::Importer::Mapper
- def initialize(mapping)
+ def initialize(mapping, options={})
@mapping = mapping
+ @options = options
end
def field_data(orig_data, field_name)
@@ -26,7 +27,7 @@
when Proc
field_mapping.call(orig_data)
when Symbol
- field_data(orig_data, field_mapping)
+ field_data(orig_data, @options[:stringify_symbols] ? field_mapping.to_s : field_mapping)
when Enumerable
field_mapping.collect {|orig_field_name| mapped_field_value(orig_data, orig_field_name)}.flatten
else