Sha256: e527f15023dcef6d8476f51d656fb33d0817b10f962889c71d307f5afc31301e
Contents?: true
Size: 986 Bytes
Versions: 5
Compression:
Stored size: 986 Bytes
Contents
require_dependency "dbd_data_engine/application_controller" module DbdDataEngine class ContextsController < ApplicationController def index graph = Dbd::Graph.new graph = graph.from_unsorted_CSV_file(filename) @contexts = graph.contexts end def new @predicates = Context.predicates end def create graph = Dbd::Graph.new @context = Dbd::Context.new() [params[:predicate], params[:object]].transpose.each do |predicate, object| context_fact = Dbd::ContextFact.new(predicate: predicate, object_type: 's', object: object) @context << context_fact end graph << @context # TODO move this to graph new_data = graph.to_CSV File.open(filename, 'a') do |f| f.syswrite new_data end end private def filename DbdDataEngine.default_CSV_location end end end
Version data entries
5 entries across 5 versions & 1 rubygems