Class: Mountebank::SymbolizeKeys

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/mountebank/helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(app = nil, options = {}) ⇒ SymbolizeKeys

Returns a new instance of SymbolizeKeys.



21
22
23
24
25
# File 'lib/mountebank/helper.rb', line 21

def initialize(app = nil, options = {})
  super(app)
  @options = options
  @content_types = Array(options[:content_type])
end

Instance Method Details

#call(environment) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/mountebank/helper.rb', line 27

def call(environment)
  @app.call(environment).on_complete do |env|
    if env[:body].is_a? Hash
      env[:body] = Helper.symbolize(env[:body])
    end
  end
end