Class: ConceptQL::Query
- Inherits:
-
Object
- Object
- ConceptQL::Query
- Extended by:
- Forwardable
- Defined in:
- lib/conceptql/query.rb
Instance Attribute Summary collapse
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
Instance Method Summary collapse
-
#initialize(db, statement, tree = Tree.new) ⇒ Query
constructor
A new instance of Query.
- #operator ⇒ Object
- #query ⇒ Object
- #sql ⇒ Object
- #types ⇒ Object
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
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
11 12 13 |
# File 'lib/conceptql/query.rb', line 11 def statement @statement end |
Instance Method Details
#operator ⇒ Object
31 32 33 |
# File 'lib/conceptql/query.rb', line 31 def operator @operator ||= tree.root(self) end |
#query ⇒ Object
19 20 21 |
# File 'lib/conceptql/query.rb', line 19 def query build_query(db) end |
#sql ⇒ Object
23 24 25 |
# File 'lib/conceptql/query.rb', line 23 def sql (tree.scope.sql(db) << operator.sql(db)).join(";\n\n") + ';' end |
#types ⇒ Object
27 28 29 |
# File 'lib/conceptql/query.rb', line 27 def types tree.root(self).types end |