Class: RestCore::ClashResponse

Inherits:
Object
  • Object
show all
Includes:
Middleware
Defined in:
lib/rest-core/middleware/clash_response.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.membersObject



6
# File 'lib/rest-core/middleware/clash_response.rb', line 6

def self.members; [:clash_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/clash_response.rb', line 9

def call env, &k
  return app.call(env, &k) if env[DRY]
  return app.call(env, &k) unless clash_response(env)

  app.call(env){ |res|
    if res[RESPONSE_BODY].kind_of?(Hash)
      yield(res.merge(RESPONSE_BODY => Clash.new(res[RESPONSE_BODY])))
    else
      yield(res)
    end
  }
end