Class: Ape::Deleter

Inherits:
Invoker show all
Defined in:
lib/ape/invokers/deleter.rb

Instance Attribute Summary

Attributes inherited from Invoker

#crumbs, #last_error, #response

Instance Method Summary collapse

Methods inherited from Invoker

#[], #[]=, #header, #initialize, #need_authentication?, #prepare_http, #restart_authent_checker, #set_header

Constructor Details

This class inherits a constructor from Ape::Invoker

Instance Method Details

#delete(req = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ape/invokers/deleter.rb', line 8

def delete( req = nil )
  req = Net::HTTP::Delete.new(AtomURI.on_the_wire(@uri)) unless req

  begin
    http = prepare_http
    
    http.start do |connection|
      @response = connection.request(req)
      
      return delete(req) if need_authentication?(req)
      restart_authent_checker
      
      return true if @response.kind_of? Net::HTTPSuccess

      @last_error = @response.message
      return false
    end
  rescue Exception
    @last_error = "Can't connect to #{@uri.host} on port #{@uri.port}: #{$!}"
    return nil
  end
end