Sha256: 72d61437fd0dd5141a1e7073778eda06e2925bf843f78abd40db2e4a3cea54d9

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

module Ldp::Client::Methods

  # Get a LDP Resource by URI
  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

  # Delete a LDP Resource by URI
  def delete url
    http.delete do |req|
      req.url url
      yield req if block_given?
    end
  end

  # Post TTL to an LDP Resource
  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

  # Update an LDP resource with TTL by URI
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ldp-0.0.2 lib/ldp/client/methods.rb