Class: CouchProxy::Rack::BulkDocs
- Defined in:
- lib/couchproxy/rack/bulk_docs.rb
Constant Summary
Constants inherited from Base
CouchProxy::Rack::Base::APPLICATION_JSON, CouchProxy::Rack::Base::DESIGN_ID, CouchProxy::Rack::Base::INVALID_JSON, CouchProxy::Rack::Base::METHODS, CouchProxy::Rack::Base::SERVER_VERSION, CouchProxy::Rack::Base::TEXT_PLAIN
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#initialize, #method_missing, #proxy_to, #proxy_to_all_nodes, #proxy_to_all_partitions, #proxy_to_any_node, #proxy_to_any_partition, #replicate_to_all_partitions, #rewrite_location, #send_error_response, #send_response, #uuids
Constructor Details
This class inherits a constructor from CouchProxy::Rack::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CouchProxy::Rack::Base
Instance Method Details
#post ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/couchproxy/rack/bulk_docs.rb', line 6 def post begin docs = JSON.parse(request.content)['docs'] rescue send_response(400, response_headers, INVALID_JSON) return end missing = docs.select {|doc| !doc['_id'] } if missing.any? uuids(missing.size) do |uuids| if uuids missing.each {|doc| doc['_id'] = uuids.shift } save(docs) else send_error_response end end else save(docs) end end |