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.
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/ldp/resource/rdf_source.rb', line 4
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
32
33
34
|
# File 'lib/ldp/resource/rdf_source.rb', line 32
def build_empty_graph
graph_class.new
end
|
#content ⇒ Object
24
25
26
|
# File 'lib/ldp/resource/rdf_source.rb', line 24
def content
graph.dump(:ttl) if graph
end
|
#create ⇒ Object
18
19
20
21
22
|
# File 'lib/ldp/resource/rdf_source.rb', line 18
def create
super do |req|
req. = { "Content-Type" => "text/turtle" }
end
end
|
#graph ⇒ Object
28
29
30
|
# File 'lib/ldp/resource/rdf_source.rb', line 28
def graph
@graph ||= new? ? build_empty_graph : build_graph(get.graph)
end
|
#graph_class ⇒ Object
graph_class may be overridden so that a subclass of RDF::Graph is returned (e.g. an ActiveTriples resource)
40
41
42
|
# File 'lib/ldp/resource/rdf_source.rb', line 40
def graph_class
RDF::Graph
end
|