class Grape::Batch::Request
Prepare batch request
Public Class Methods
new(env, batch_request)
click to toggle source
# File lib/grape/batch/request.rb, line 7 def initialize(env, batch_request) @env = env @batch_request = batch_request end
Public Instance Methods
body()
click to toggle source
# File lib/grape/batch/request.rb, line 20 def body @body ||= @batch_request['body'].is_a?(Hash) ? @batch_request['body'] : {} end
build()
click to toggle source
# File lib/grape/batch/request.rb, line 32 def build @env['REQUEST_METHOD'] = method @env['PATH_INFO'] = path @env['QUERY_STRING'] = query_string @env['rack.input'] = rack_input @env end
method()
click to toggle source
# File lib/grape/batch/request.rb, line 12 def method @batch_request['method'] end
path()
click to toggle source
# File lib/grape/batch/request.rb, line 16 def path @batch_request['path'] end
query_string()
click to toggle source
# File lib/grape/batch/request.rb, line 24 def query_string @query_string ||= method == 'GET' ? URI.encode_www_form(Converter.encode(body).to_a) : '' end
rack_input()
click to toggle source
# File lib/grape/batch/request.rb, line 28 def rack_input @rack_input ||= method == 'GET' ? '{}' : StringIO.new(MultiJson.encode(body)) end