Class: Ldp::Client
Defined Under Namespace
Modules: Methods
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
Instance Method Summary collapse
-
#find_or_initialize(subject) ⇒ Object
Find or initialize a new LDP resource by URI.
-
#initialize(*http_client) ⇒ Client
constructor
A new instance of Client.
Methods included from Methods
Constructor Details
#initialize(*http_client) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 |
# File 'lib/ldp/client.rb', line 12 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 |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
10 11 12 |
# File 'lib/ldp/client.rb', line 10 def http @http end |
Instance Method Details
#find_or_initialize(subject) ⇒ Object
Find or initialize a new LDP resource by URI
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ldp/client.rb', line 21 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 |