Class: ActiveResource::Persistent::HTTP

Inherits:
Net::HTTP::Persistent
  • Object
show all
Defined in:
lib/active_resource/persistent/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, proxy) ⇒ HTTP

Returns a new instance of HTTP.



6
7
8
9
# File 'lib/active_resource/persistent/http.rb', line 6

def initialize(site, proxy)
  super('active_resource', proxy)
  @site = site
end

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



11
12
13
# File 'lib/active_resource/persistent/http.rb', line 11

def site
  @site
end

Instance Method Details

#delete(path, headers) ⇒ Object



30
31
32
33
# File 'lib/active_resource/persistent/http.rb', line 30

def delete(path, headers)
  req = Net::HTTP::Delete.new(path, headers)
  request(@site, req)
end

#get(path, headers) ⇒ Object



13
14
15
16
# File 'lib/active_resource/persistent/http.rb', line 13

def get(path, headers)
  req = Net::HTTP::Get.new(path, headers)
  request(@site, req)
end

#head(path, headers) ⇒ Object



35
36
37
38
# File 'lib/active_resource/persistent/http.rb', line 35

def head(path, headers)
  req = Net::HTTP::Head.new(path, headers)
  request(@site, req)
end

#post(path, data, headers) ⇒ Object



18
19
20
21
22
# File 'lib/active_resource/persistent/http.rb', line 18

def post(path, data, headers)
  req = Net::HTTP::Post.new(path, headers)
  req.body = data
  request(@site, req)
end

#put(path, data, headers) ⇒ Object



24
25
26
27
28
# File 'lib/active_resource/persistent/http.rb', line 24

def put(path, data, headers)
  req = Net::HTTP::Put.new(path, headers)
  req.body = data
  request(@site, req)
end

#use_ssl=(value) ⇒ Object

SSL support



44
45
46
47
48
# File 'lib/active_resource/persistent/http.rb', line 44

def use_ssl=(value)
  expected_scheme = value ? 'https' : 'http'
  site.scheme == expected_scheme or
    raise ArgumentError, "Site scheme should be #{expected_scheme.inspect}"
end