Sha256: ee24430aba1f938572408de3f41be4a530e889420a968249102cc74dbc78ad3c

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 Bytes

Contents

module Ldp
  class Container < Resource
    ##
    # Add a resource to the LDP container
    def add *args
      # slug, graph
      # graph
      # slug

      case
      when (args.length > 2 || args.length == 0)

      when (args.length == 2)
        slug, graph = args
      when (args.first.is_a? RDF::Graph)
        slug = nil
        graph = args.first
      else
        slug = args.first
        graph = RDF::Graph.new
      end

      resp = client.post subject, graph.dump(:ttl) do |req|
        req.headers['Slug'] = slug
      end

      subject = resp.headers['Location']
      return client.find_or_initialize subject
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ldp-0.0.3 lib/ldp/container.rb
ldp-0.0.2 lib/ldp/container.rb