Sha256: d494c4187fda7426ecf9d9c37d348506a2f930a368c5733930046c9cd8883049

Contents?: true

Size: 810 Bytes

Versions: 3

Compression:

Stored size: 810 Bytes

Contents

require_dependency "dbd_data_engine/application_controller"

module DbdDataEngine
  class ResourcesController < ApplicationController
    def index
    end

    def new
      @predicates = ['schema:givenName','schema:familyName']
    end

    def create
      graph = Dbd::Graph.new
      @resource = Dbd::Resource.new(context_subject: Dbd::Context.new_subject)
      [params[:predicate], params[:object]].transpose.each do |predicate, object|
        fact = Dbd::Fact.new({predicate: predicate,
                              object:    object})
        @resource << fact
      end
      graph << @resource
      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

3 entries across 3 versions & 1 rubygems

Version Path
dbd_data_engine-0.0.4 app/controllers/dbd_data_engine/resources_controller.rb
dbd_data_engine-0.0.3 app/controllers/dbd_data_engine/resources_controller.rb
dbd_data_engine-0.0.2 app/controllers/dbd_data_engine/resources_controller.rb