Class: ConceptQL::Query

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/conceptql/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, statement, tree = Tree.new) ⇒ Query

Returns a new instance of Query.



12
13
14
15
16
17
# File 'lib/conceptql/query.rb', line 12

def initialize(db, statement, tree = Tree.new)
  @db = db
  @db.extend_datasets(ConceptQL::Behaviors::Preppable)
  @statement = statement
  @tree = tree
end

Instance Attribute Details

#statementObject (readonly)

Returns the value of attribute statement.



11
12
13
# File 'lib/conceptql/query.rb', line 11

def statement
  @statement
end

Instance Method Details

#operatorObject



31
32
33
# File 'lib/conceptql/query.rb', line 31

def operator
  @operator ||= tree.root(self)
end

#queryObject



19
20
21
# File 'lib/conceptql/query.rb', line 19

def query
  build_query(db)
end

#sqlObject



23
24
25
# File 'lib/conceptql/query.rb', line 23

def sql
  (tree.scope.sql(db) << operator.sql(db)).join(";\n\n") + ';'
end

#typesObject



27
28
29
# File 'lib/conceptql/query.rb', line 27

def types
  tree.root(self).types
end