Sha256: d9ace41eefa8fd9e0d10b91bbb88e798e38aaca94859f7d8e13a01361ac8d3d1

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

require 'faraday'

module Ldp
  class Client

    require 'ldp/client/methods'

    include Ldp::Client::Methods
    
    attr_reader :http

    def initialize *http_client
      if http_client.length == 1 and http_client.first.is_a? Faraday::Connection
        @http = http_client.first
      else 
        @http = Faraday.new *http_client  
      end
    end

    # Find or initialize a new LDP resource by URI
    def find_or_initialize subject
      data = get(subject)

      unless data.is_a? Response
        raise "#{subject} is not an LDP Resource"
      end

      if data.container?
        Container.new self, subject, data
      else  
        Resource.new self, subject, data
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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