Module: Ldp::Client::Methods

Included in:
Ldp::Client
Defined in:
lib/ldp/client/methods.rb

Instance Method Summary collapse

Instance Method Details

#delete(url) ⇒ Object

Delete a LDP Resource by URI



21
22
23
24
25
26
# File 'lib/ldp/client/methods.rb', line 21

def delete url
  http.delete do |req|
    req.url url
    yield req if block_given?
  end
end

#get(url) ⇒ Object

Get a LDP Resource by URI



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ldp/client/methods.rb', line 7

def get url
  resp = http.get do |req|                          
    req.url url
    yield req if block_given?
  end

  if Ldp::Response.resource? resp
    Ldp::Response.wrap self, resp
  else
    resp
  end
end

#loggerObject



2
3
4
# File 'lib/ldp/client/methods.rb', line 2

def logger
  Ldp.logger
end

#post(url, body = nil, headers = {}) ⇒ Object

Post TTL to an LDP Resource



29
30
31
32
33
34
35
36
37
# File 'lib/ldp/client/methods.rb', line 29

def post url, body = nil, headers = {}
  logger.debug "POST [#{url}] #{body}"
  http.post do |req|
    req.url url
    req.headers = default_headers.merge headers
    req.body = body
    yield req if block_given?
  end
end

#put(url, body, headers = {}) ⇒ Object

Update an LDP resource with TTL by URI



40
41
42
43
44
45
46
47
48
# File 'lib/ldp/client/methods.rb', line 40

def put url, body, headers = {}
  logger.debug "PUT [#{url}] #{body}"
  http.put do |req|
    req.url url
    req.headers = default_headers.merge headers
    req.body = body
    yield req if block_given?
  end
end