Module: Ldp::Client::Methods
- Included in:
- Ldp::Client
- Defined in:
- lib/ldp/client/methods.rb
Instance Method Summary collapse
-
#delete(url) ⇒ Object
Delete a LDP Resource by URI.
-
#get(url) ⇒ Object
Get a LDP Resource by URI.
-
#post(url, body = nil, headers = {}) ⇒ Object
Post TTL to an LDP Resource.
-
#put(url, body) ⇒ Object
Update an LDP resource with TTL by URI.
Instance Method Details
#delete(url) ⇒ Object
Delete a LDP Resource by URI
18 19 20 21 22 23 |
# File 'lib/ldp/client/methods.rb', line 18 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
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ldp/client/methods.rb', line 4 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 |
#post(url, body = nil, headers = {}) ⇒ Object
Post TTL to an LDP Resource
26 27 28 29 30 31 32 33 |
# File 'lib/ldp/client/methods.rb', line 26 def post url, body = nil, headers = {} http.post do |req| req.url url req.headers = {"Content-Type"=>"text/turtle"}.merge headers req.body = body yield req if block_given? end end |
#put(url, body) ⇒ Object
Update an LDP resource with TTL by URI
36 37 38 39 40 41 42 43 |
# File 'lib/ldp/client/methods.rb', line 36 def put url, body http.put do |req| req.url url req.headers['Content-Type'] = 'text/turtle' req.body = body yield req if block_given? end end |