Class: SabredavClient::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/sabredav_client/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, client, path) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
12
13
# File 'lib/sabredav_client/request.rb', line 6

def initialize(method, client, path)
  @client  = client
  @path    = "#{client.base_path}/#{path}"
  @http    = build_http
  @request = build_request(method)

  add_auth
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/sabredav_client/request.rb', line 4

def client
  @client
end

#httpObject (readonly)

Returns the value of attribute http.



4
5
6
# File 'lib/sabredav_client/request.rb', line 4

def http
  @http
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/sabredav_client/request.rb', line 3

def path
  @path
end

#requestObject (readonly)

Returns the value of attribute request.



4
5
6
# File 'lib/sabredav_client/request.rb', line 4

def request
  @request
end

Instance Method Details

#add_body(body) ⇒ Object



15
16
17
# File 'lib/sabredav_client/request.rb', line 15

def add_body(body)
  request.body = body
end

#add_header(data) ⇒ Object



19
20
21
22
23
24
# File 'lib/sabredav_client/request.rb', line 19

def add_header(data)
  request['Content-Length']  = data[:content_length]  if data[:content_length]
  request['If-Match']        = data[:if_match]        if data[:if_match]
  request['Content-Type']    = data[:content_type]    if data[:content_type]
  request['DAV']             = data[:dav]             if data[:dav]
end

#runObject



26
27
28
# File 'lib/sabredav_client/request.rb', line 26

def run
  @http.request(request)
end