Class: DbdDataEngine::ResourcesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DbdDataEngine::ResourcesController
- Defined in:
- app/controllers/dbd_data_engine/resources_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/dbd_data_engine/resources_controller.rb', line 15 def create # FIXME refactor to smaller function (green first, refactor next) @context = Context.default_from_params(params[:context], current_graph) @resource = Dbd::Resource.new(context_subject: @context.subject) [params[:predicate], params[:object]].transpose.each do |predicate, object| @resource << Dbd::Fact.new( predicate: predicate, object_type: 's', object: object) end # prepare the graph to append append_graph = Dbd::Graph.new append_graph << @context unless @context.first.time_stamp # only if not yet persisted? append_graph << @resource # TODO this can probably move to Dbd::Graph#append_to_file(filename) append_csv = append_graph.to_CSV File.open(filename, 'a') do |f| f.syswrite append_csv end redirect_to('/data/resources') end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/dbd_data_engine/resources_controller.rb', line 6 def index @resources_with_contexts = resources_with_contexts(current_graph) end |
#new ⇒ Object
10 11 12 13 |
# File 'app/controllers/dbd_data_engine/resources_controller.rb', line 10 def new @contexts = ['public today', 'personal today', 'business today'] @predicates = Resource.used_predicates end |