Class: Apis::Middleware::Response::Json
- Inherits:
-
Object
- Object
- Apis::Middleware::Response::Json
- Defined in:
- lib/apis/middleware/response/json.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil) ⇒ Json
constructor
A new instance of Json.
Constructor Details
#initialize(app = nil) ⇒ Json
Returns a new instance of Json.
8 9 10 |
# File 'lib/apis/middleware/response/json.rb', line 8 def initialize(app = nil) @app = app end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
7 8 9 |
# File 'lib/apis/middleware/response/json.rb', line 7 def app @app end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/apis/middleware/response/json.rb', line 12 def call(env) env.body = case env.body when '' nil when 'true' true when 'false' false else ::MultiJson.decode(env.body) end @app.call(env) if @app end |