Class: Rack::Typhoeus::Middleware::ParamsDecoder

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/rack/typhoeus/middleware/params_decoder.rb,
lib/rack/typhoeus/middleware/params_decoder/helper.rb

Overview

This Rack middleware takes care of the proper deserialization of the nested params encoded by Typhoeus.

Examples:

Require the railtie when using Rails.

require 'typhoeus/railtie'

Include the middleware for Rack based applications.

use Rack::Typhoeus::Middleware::ParamsDecoder

Use the helper directly. Not recommended as b/c the interface might change.

require 'rack/typhoeus/middleware/params_decoder/helper'
include Rack::Typhoeus::Middleware::ParamsDecoder::Helper
decode!(params)

Author:

  • Dwayne Macgowan

Since:

  • 0.5.4

Defined Under Namespace

Modules: Helper

Instance Method Summary collapse

Methods included from Helper

#decode, #decode!, #decode_typhoeus_arrays

Constructor Details

#initialize(app) ⇒ ParamsDecoder

Returns a new instance of ParamsDecoder.

Since:

  • 0.5.4



26
27
28
# File 'lib/rack/typhoeus/middleware/params_decoder.rb', line 26

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Since:

  • 0.5.4



30
31
32
33
34
# File 'lib/rack/typhoeus/middleware/params_decoder.rb', line 30

def call(env)
  req = Rack::Request.new(env)
  decode(req.params).each_pair { |k, v| update_params req, k, v }
  @app.call(env)
end