Class: Ldp::Resource::RdfSource
Instance Attribute Summary
#client, #subject
Instance Method Summary
collapse
#current?, #delete, #get, #head, #new?, #reload, #retrieved_content?, #save, #subject_uri, #update, #update_cached_get
Constructor Details
#initialize(client, subject, graph_or_response = nil, base_path = '') ⇒ RdfSource
Returns a new instance of RdfSource.
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/ldp/resource/rdf_source.rb', line 6
def initialize client, subject, graph_or_response = nil, base_path = ''
super
case graph_or_response
when RDF::Graph
@graph = graph_or_response
when Ldp::Response
when NilClass
else
raise ArgumentError, "Third argument to #{self.class}.new should be a RDF::Graph or a Ldp::Response. You provided #{graph_or_response.class}"
end
end
|
Instance Method Details
#build_empty_graph ⇒ Object
34
35
36
|
# File 'lib/ldp/resource/rdf_source.rb', line 34
def build_empty_graph
graph_class.new
end
|
#content ⇒ Object
26
27
28
|
# File 'lib/ldp/resource/rdf_source.rb', line 26
def content
graph.dump(:ttl) if graph
end
|
#create ⇒ Object
20
21
22
23
24
|
# File 'lib/ldp/resource/rdf_source.rb', line 20
def create
super do |req|
req.["Content-Type"] = "text/turtle"
end
end
|
#graph ⇒ Object
30
31
32
|
# File 'lib/ldp/resource/rdf_source.rb', line 30
def graph
@graph ||= new? ? build_empty_graph : build_graph(response_as_graph(get))
end
|
#graph_class ⇒ Object
graph_class may be overridden so that a subclass of RDF::Graph is returned (e.g. an ActiveTriples resource)
42
43
44
|
# File 'lib/ldp/resource/rdf_source.rb', line 42
def graph_class
RDF::Graph
end
|