Class: Ldp::Client

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

Defined Under Namespace

Modules: Methods

Instance Attribute Summary collapse

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(*args) ⇒ Client

Returns a new instance of Client.



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

def initialize(*args)
  http_client, options = if args.length == 2
                           args
                         elsif args.length == 1 && args.first.is_a?(Faraday::Connection)
                           [args.first, {}]
                         elsif args.length == 1
                           [nil, args.first]
                         else
                           raise ArgumentError
                         end

  @options = options

  initialize_http_client(http_client || options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

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

Find or initialize a new LDP resource by URI



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

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

  Ldp::Resource.for(self, subject, data)
end

#loggerObject



34
35
36
# File 'lib/ldp/client.rb', line 34

def logger
  Ldp.logger
end