Sha256: 76af77517ea1f856efc11ac9ad8d3d0a486314cdf599b8dd1f63f0ef0ec83724

Contents?: true

Size: 795 Bytes

Versions: 10

Compression:

Stored size: 795 Bytes

Contents

require_relative 'node'
require_relative '../tree'

module ConceptQL
  module Nodes
    class Concept < Node
      attr :statement
      def query(db)
        set_statement(db)
        stream.evaluate(db)
      end

      def children
        @children ||= [ Tree.new.root(self) ]
      end

      def graph_prep(db)
        set_statement(db)
        @arguments = [description(db)]
      end

      private
      def set_statement(db)
        @statement ||= db[:concepts].where(concept_id: arguments.first).select_map(:statement).first.tap { |f| ConceptQL.logger.debug f.inspect }.to_hash
      end

      def description(db)
        @description ||= db[:concepts].where(concept_id: arguments.first).select_map(:label).first
      end

      def db
        tree.db
      end
    end
  end
end


Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
conceptql-0.1.1 lib/conceptql/nodes/concept.rb
conceptql-0.1.0 lib/conceptql/nodes/concept.rb
conceptql-0.0.9 lib/conceptql/nodes/concept.rb
conceptql-0.0.8 lib/conceptql/nodes/concept.rb
conceptql-0.0.7 lib/conceptql/nodes/concept.rb
conceptql-0.0.6 lib/conceptql/nodes/concept.rb
conceptql-0.0.5 lib/conceptql/nodes/concept.rb
conceptql-0.0.4 lib/conceptql/nodes/concept.rb
conceptql-0.0.3 lib/conceptql/nodes/concept.rb
conceptql-0.0.1 lib/conceptql/nodes/concept.rb