Class: Ridley::Middleware::ChefResponse

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/ridley/middleware/chef_response.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.success?(env) ⇒ Boolean

Determines if a response from the Chef server was successful

Parameters:

  • env (Hash)

    a faraday request env

Returns:

  • (Boolean)


12
13
14
# File 'lib/ridley/middleware/chef_response.rb', line 12

def success?(env)
  (200..210).to_a.index(env[:status].to_i) ? true : false
end

Instance Method Details

#on_complete(env) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/ridley/middleware/chef_response.rb', line 17

def on_complete(env)
  Ridley.log.debug("Handling Chef Response")
  Ridley.log.debug(env)
  
  unless self.class.success?(env)
    Ridley.log.debug("Error encounted in Chef Response")
    raise Errors::HTTPError.fabricate(env)
  end
end