-
-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathget_json.rb
More file actions
28 lines (28 loc) · 689 Bytes
/
get_json.rb
File metadata and controls
28 lines (28 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Acme
class GetJson < Grape::API
format :json
desc 'Flips reticulated in a collection of splines passed as JSON in a query string.'
resource :reticulated_splines do
before do
params.each_pair do |k, v|
params[k] = begin
JSON.parse(v)
rescue StandardError
v
end
end
end
params do
requires :splines, type: Array do
requires :id, type: Integer
requires :reticulated, type: Boolean
end
end
get do
params[:splines].map do |spline|
spline.merge(reticulated: !spline[:reticulated])
end
end
end
end
end