Sha256: 5effa0275114df84cda3ca518de4b717e69f612fa8702fff3ed06869996b9ff6

Contents?: true

Size: 483 Bytes

Versions: 20

Compression:

Stored size: 483 Bytes

Contents

require 'rest-core/middleware'
require 'rest-core/util/smash'

class RestCore::SmashResponse
  def self.members; [:smash_response]; end
  include RestCore::Middleware

  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
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rest-core-3.6.0 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.92 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.91 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.9 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.8 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.7 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.6 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.5 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.4 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.3 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.2 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.1 lib/rest-core/middleware/smash_response.rb
rest-core-3.5.0 lib/rest-core/middleware/smash_response.rb
rest-core-3.4.1 lib/rest-core/middleware/smash_response.rb
rest-core-3.4.0 lib/rest-core/middleware/smash_response.rb
rest-core-3.3.3 lib/rest-core/middleware/smash_response.rb
rest-core-3.3.2 lib/rest-core/middleware/smash_response.rb
rest-core-3.3.1 lib/rest-core/middleware/smash_response.rb
rest-core-3.3.0 lib/rest-core/middleware/smash_response.rb
rest-core-3.2.0 lib/rest-core/middleware/smash_response.rb