Class: Excon::Middleware::Expects

Inherits:
Base
  • Object
show all
Defined in:
lib/excon/middlewares/expects.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#error_call, #initialize, #request_call

Constructor Details

This class inherits a constructor from Excon::Middleware::Base

Class Method Details

.valid_parameter_keysObject


5
6
7
8
9
# File 'lib/excon/middlewares/expects.rb', line 5

def self.valid_parameter_keys
  [
    :expects
  ]
end

Instance Method Details

#response_call(datum) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/excon/middlewares/expects.rb', line 11

def response_call(datum)
  if datum.has_key?(:expects) && ![*datum[:expects]].include?(datum[:response][:status])
    raise(
      Excon::Errors.status_error(
        datum.reject {|key,value| key == :response},
        Excon::Response.new(datum[:response])
      )
    )
  else
    @stack.response_call(datum)
  end
end