lib/ferret_adapter/adapter.rb in dm-ferret-adapter-1.1.0.rc2 vs lib/ferret_adapter/adapter.rb in dm-ferret-adapter-1.1.0.rc3

- old
+ new

@@ -10,11 +10,11 @@ end end def create(resources) resources.each do |resource| - attributes = resource.attributes(:field).to_mash + attributes = DataMapper::Ext::Hash.to_mash(resource.attributes(:field)) # Since we don't inspect the models before generating the indices, # we'll map the resource's key to the :id column. attributes[:id] ||= resource.key.first attributes[:_type] = resource.model.name @@ -30,10 +30,10 @@ key = query.model.key(name).first ferret_query = dm_query_to_ferret_query(query) @index.search(ferret_query, :limit => query.limit).map do |lazy_doc| - fields.map { |p| [ p, p.typecast(lazy_doc[p.field]) ] }.to_hash.update( + DataMapper::Ext::Array.to_hash(fields.map { |p| [ p, p.typecast(lazy_doc[p.field]) ] }).update( key.field => key.typecast(lazy_doc[:id]) ) end end