Class: Ldp::Client

Inherits:
Object
  • Object
show all
Includes:
Methods
Defined in:
lib/ldp/client.rb

Defined Under Namespace

Modules: Methods

Instance Attribute Summary

Attributes included from Methods

#http

Instance Method Summary collapse

Methods included from Methods

#delete, #get, #head, #initialize_http_client, #patch, #post, #put

Constructor Details

#initialize(*http_client) ⇒ Client

Returns a new instance of Client.



9
10
11
# File 'lib/ldp/client.rb', line 9

def initialize *http_client
  initialize_http_client *http_client
end

Instance Method Details

#find_or_initialize(subject, options = {}) ⇒ Object

Find or initialize a new LDP resource by URI



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ldp/client.rb', line 14

def find_or_initialize subject, options = {}
  data = get(subject, options = {})

  case
  when !data.is_a?(Ldp::Response)
    Resource::BinarySource.new self, subject, data
  when data.container?
    Ldp::Container.new_from_response self, subject, data
  when data.resource?
    Resource::RdfSource.new self, subject, data
  else
    Resource::BinarySource.new self, subject, data
  end
end

#loggerObject



29
30
31
# File 'lib/ldp/client.rb', line 29

def logger
  Ldp.logger
end