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.



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

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.



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

def options
  @options
end

Instance Method Details

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

Find or initialize a new LDP resource by URI



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

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

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

#loggerObject



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

def logger
  Ldp.logger
end