Class: Rack::JsonResponseWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/json_response_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ JsonResponseWrapper

Returns a new instance of JsonResponseWrapper.



3
4
5
# File 'lib/rack/json_response_wrapper.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rack/json_response_wrapper.rb', line 7

def call(env)
  response = @app.call(env)

  if should_wrap? env, response
    wrap_response(response)
  else
    response
  end
end