Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

map results of reduces into an array of OpenStructs, should make acce…

…ssing/working with them a bit easier. Will probably try to do something a bit more sophisticated eventually, but seems a step in the right direction
  • Loading branch information...
commit 452c96bdd35726137a95720a65762b3df2bdf92b 1 parent e0833e9
Wesley Beary authored
View
3  adapters/dm-couchdb-adapter/lib/couchdb_adapter.rb
@@ -4,6 +4,7 @@
gem 'dm-core', DataMapper::More::CouchDBAdapter::VERSION
require 'dm-core'
require 'json'
+require 'ostruct'
require 'net/http'
require 'uri'
require Pathname(__FILE__).dirname + 'couchdb_adapter/json_object'
@@ -126,7 +127,7 @@ def read_many(query)
if doc['rows'].empty?
[]
elsif query.view && query.model.views[query.view.to_sym].has_key?('reduce')
- doc['rows']
+ doc['rows'].map {|row| OpenStruct.new(row)}
else
Collection.new(query) do |collection|
doc['rows'].each do |doc|
View
2  adapters/dm-couchdb-adapter/spec/couchdb_adapter_spec.rb
@@ -225,7 +225,7 @@ class Company
it "should return a value from a view with reduce defined" do
pending("No CouchDB connection.") if @no_connection
- User.count.should == [ { "value" => User.all.length, "key" => nil } ]
+ User.count.should == [ OpenStruct.new({ "value" => User.all.length, "key" => nil }) ]
end
def create_procedures
Please sign in to comment.
Something went wrong with that request. Please try again.