Class: Activecube::Processor::Composer
- Inherits:
-
Object
- Object
- Activecube::Processor::Composer
- Defined in:
- lib/activecube/processor/composer.rb
Instance Attribute Summary collapse
-
#cube_query ⇒ Object
readonly
Returns the value of attribute cube_query.
-
#models ⇒ Object
readonly
Returns the value of attribute models.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #build_query ⇒ Object
- #connection ⇒ Object
-
#initialize(cube_query) ⇒ Composer
constructor
A new instance of Composer.
Constructor Details
#initialize(cube_query) ⇒ Composer
Returns a new instance of Composer.
11 12 13 |
# File 'lib/activecube/processor/composer.rb', line 11 def initialize cube_query @cube_query = cube_query end |
Instance Attribute Details
#cube_query ⇒ Object (readonly)
Returns the value of attribute cube_query.
10 11 12 |
# File 'lib/activecube/processor/composer.rb', line 10 def cube_query @cube_query end |
#models ⇒ Object (readonly)
Returns the value of attribute models.
10 11 12 |
# File 'lib/activecube/processor/composer.rb', line 10 def models @models end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
10 11 12 |
# File 'lib/activecube/processor/composer.rb', line 10 def query @query end |
Instance Method Details
#build_query ⇒ Object
15 16 17 |
# File 'lib/activecube/processor/composer.rb', line 15 def build_query @query = compose_queries optimize! ranked_tables end |
#connection ⇒ Object
19 20 21 22 23 24 |
# File 'lib/activecube/processor/composer.rb', line 19 def connection connections = models.map(&:connection).compact.uniq raise "No connection found for query" if connections.empty? raise "Tables #{models.map(&:name).join(',')} mapped to multiple connections, can not query" if connections.count>1 connections.first end |