Class: RoadForest::RDFModel

Inherits:
Model
  • Object
show all
Includes:
RoadForest::RDF::Etagging
Defined in:
lib/roadforest/model.rb

Instance Attribute Summary

Attributes inherited from Model

#data, #params, #response_values, #route_name, #services

Instance Method Summary collapse

Methods included from RoadForest::RDF::Etagging

#blank_mapped, #etag_from, #sorted_quads

Methods inherited from Model

#authentication_challenge, #authorization, #canonical_host, #canonical_uri, #delete, #exists?, #expires, #initialize, #last_modified, #model_for, #my_path, #my_url, #path_for, #processed, #required_grants, #reset, #response_data, #response_data=, #response_location, #response_location=, #type_handling, #url_for

Constructor Details

This class inherits a constructor from RoadForest::Model

Instance Method Details

#add_child(focus) ⇒ Object



154
155
156
# File 'lib/roadforest/model.rb', line 154

def add_child(focus)
  new_graph
end

#add_graph_child(graph) ⇒ Object



149
150
151
152
# File 'lib/roadforest/model.rb', line 149

def add_graph_child(graph)
  add_child(start_focus(graph))
  new_graph
end

#copy_model(node, route_name, params = nil) {|copier| ... } ⇒ Object

Yields:

  • (copier)


174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/roadforest/model.rb', line 174

def copy_model(node, route_name, params=nil)
  params ||= {}

  url = url_for(route_name, params)
  source_model = model_for(route_name, params)

  access = RDF::CopyManager.new
  access.source_graph = source_model.current_graph
  access.target_graph = node.access_manager.destination_graph
  copier = RDF::GraphFocus.new(access, url)

  yield copier if block_given?
  copier
end

#current_graphObject



197
198
199
200
# File 'lib/roadforest/model.rb', line 197

def current_graph
  return response_data if response_values.has_key?(:data)
  new_graph
end

#etagObject



189
190
191
# File 'lib/roadforest/model.rb', line 189

def etag
  @etag ||= etag_from(etag_graph)
end

#etag_graphObject



193
194
195
# File 'lib/roadforest/model.rb', line 193

def etag_graph
  current_graph
end

#fill_graph(graph) ⇒ Object



162
163
# File 'lib/roadforest/model.rb', line 162

def fill_graph(graph)
end

#graph_update(focus) ⇒ Object



145
146
147
# File 'lib/roadforest/model.rb', line 145

def graph_update(focus)
  fill_graph(focus)
end

#new_graphObject



202
203
204
205
206
207
# File 'lib/roadforest/model.rb', line 202

def new_graph
  graph = ::RDF::Graph.new
  focus = start_focus(graph, my_url)
  fill_graph(focus)
  self.response_data = graph
end

#retrieveObject



158
159
160
# File 'lib/roadforest/model.rb', line 158

def retrieve
  new_graph
end

#start_focus(graph, resource_url = nil) {|focus| ... } ⇒ Object

Yields:

  • (focus)


165
166
167
168
169
170
171
172
# File 'lib/roadforest/model.rb', line 165

def start_focus(graph, resource_url=nil)
  access = RDF::WriteManager.new
  access.source_graph = graph
  focus = RDF::GraphFocus.new(access, resource_url || my_url)

  yield focus if block_given?
  return focus
end

#update(graph) ⇒ Object



141
142
143
# File 'lib/roadforest/model.rb', line 141

def update(graph)
  graph_update(start_focus(graph))
end