Class: Ridley::Middleware::ChefResponse

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

logger, #logger, set_logger

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)


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

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

Instance Method Details

#on_complete(env) ⇒ Object



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

def on_complete(env)
  log.debug { "==> handling Chef response" }
  log.debug { "request env: #{env}" }

  unless self.class.success?(env)
    log.debug { "** error encounted in Chef response" }
    raise Errors::HTTPError.fabricate(env)
  end
end