summaryrefslogtreecommitdiff
path: root/lib/nanoparticle.rb
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2018-11-26 15:29:26 +0000
committergebele <gebele@in-silico.ch>2018-11-26 15:29:26 +0000
commit9750e0309500259e9a56e267ce87984fb5bb5e53 (patch)
tree17db0a8246578729e5309ef3bf4f71404c3f7479 /lib/nanoparticle.rb
parente3ae34a75ed7a503078c3c2cdf95f1500d6e2b73 (diff)
clean out; better response codes; prepare for batch
Diffstat (limited to 'lib/nanoparticle.rb')
-rw-r--r--lib/nanoparticle.rb30
1 files changed, 0 insertions, 30 deletions
diff --git a/lib/nanoparticle.rb b/lib/nanoparticle.rb
deleted file mode 100644
index 332493d..0000000
--- a/lib/nanoparticle.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# Get all Nanoparticles
-get "/nanoparticle/?" do
- nanoparticles = Nanoparticle.all
- case @accept
- when "text/uri-list"
- uri_list = nanoparticles.collect{|nanoparticle| uri("/nanoparticle/#{nanoparticle.id}")}
- return uri_list.join("\n") + "\n"
- when "application/json"
- nanoparticles = JSON.parse nanoparticles.to_json
- nanoparticles.each_index do |idx|
- nanoparticles[idx][:URI] = uri("/nanoparticle/#{nanoparticles[idx]["_id"]["$oid"]}")
- end
- return nanoparticles.to_json
- else
- bad_request_error "Mime type #{@accept} is not supported."
- end
-end
-
-# Get a nanoparticle
-get "/nanoparticle/:id/?" do
- case @accept
- when "application/json"
- nanoparticle = Nanoparticle.find :id => params[:id]
- not_found_error "Nanoparticle with id: #{params[:id]} not found." unless nanoparticle
- nanoparticle[:URI] = uri("/nanoparticle/#{nanoparticle.id}")
- return nanoparticle.to_json
- else
- bad_request_error "Mime type #{@accept} is not supported."
- end
-end