Class: RestCore::SmashResponse
- Inherits:
-
Object
- Object
- RestCore::SmashResponse
- Includes:
- Middleware
- Defined in:
- lib/rest-core/middleware/smash_response.rb
Constant Summary
Constants included from Middleware
Constants included from RestCore
ASYNC, CLIENT, DRY, FAIL, HIJACK, LOG, PROMISE, REQUEST_HEADERS, REQUEST_METHOD, REQUEST_PATH, REQUEST_PAYLOAD, REQUEST_QUERY, REQUEST_URI, RESPONSE_BODY, RESPONSE_HEADERS, RESPONSE_KEY, RESPONSE_SOCKET, RESPONSE_STATUS, Simple, TIMER, Universal, VERSION
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Middleware
contain_binary?, #contain_binary?, escape, #escape, #fail, #id, included, #log, merge_hash, #merge_hash, #percent_encode, percent_encode, request_uri, #request_uri, #run, #string_keys, string_keys
Methods included from RestCore
Class Method Details
.members ⇒ Object
6 |
# File 'lib/rest-core/middleware/smash_response.rb', line 6 def self.members; [:smash_response]; end |
Instance Method Details
#call(env, &k) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rest-core/middleware/smash_response.rb', line 9 def call env, &k return app.call(env, &k) if env[DRY] return app.call(env, &k) unless smash_response(env) app.call(env){ |res| if res[RESPONSE_BODY].kind_of?(Hash) yield(res.merge(RESPONSE_BODY => Smash.new(res[RESPONSE_BODY]))) else yield(res) end } end |