Sha256: 77db82fc7f44242e9ea8398c84d3b7029aaab2fe5680884707553e1b5680c95d

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

require_dependency "dbd_onto_engine/application_controller"

module DbdOntoEngine
  class OntologiesController < ApplicationController

    def index
      @ontologies = supported_ontologies
    end

    def show
      @ontology = params[:id]
      @ontology_predicates = resources(ontology)
    end

  private

    def supported_ontologies
      %w{context meta schema}
    end

    def ontology_class(ontology_name)
      if supported_ontologies.include? @ontology
        "DbdOnto::#{@ontology.capitalize}".constantize
      else
        raise "Invalid ontology"
      end
    end

    def ontology
      ontology_class(@ontology).new
    end

    # TODO move this to the Dbd::Graph#resources
    def resources(graph)
      graph.subjects.map{ |s| graph.by_subject(s) }.select{ |cs| cs.first.class == Dbd::Fact }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dbd_onto_engine-0.0.6 app/controllers/dbd_onto_engine/ontologies_controller.rb