Class: JsonQL::Executor
- Inherits:
-
Object
- Object
- JsonQL::Executor
- Defined in:
- lib/json_q_l/executor.rb
Instance Attribute Summary collapse
-
#dataset ⇒ Object
readonly
Returns the value of attribute dataset.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #execute(query) ⇒ Object
- #filtered_table ⇒ Object
-
#initialize(dataset) ⇒ Executor
constructor
A new instance of Executor.
- #selected_columns ⇒ Object
- #tables ⇒ Object
Constructor Details
#initialize(dataset) ⇒ Executor
Returns a new instance of Executor.
3 4 5 |
# File 'lib/json_q_l/executor.rb', line 3 def initialize(dataset) @dataset = dataset end |
Instance Attribute Details
#dataset ⇒ Object (readonly)
Returns the value of attribute dataset.
35 36 37 |
# File 'lib/json_q_l/executor.rb', line 35 def dataset @dataset end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
35 36 37 |
# File 'lib/json_q_l/executor.rb', line 35 def parser @parser end |
Instance Method Details
#execute(query) ⇒ Object
7 8 9 10 11 |
# File 'lib/json_q_l/executor.rb', line 7 def execute(query) @parser = Parser.new(query) selected_columns end |
#filtered_table ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/json_q_l/executor.rb', line 21 def filtered_table if parser.where_index tables.map do |table| table if parser.filter_conditions_from_tokens.call(table) end.compact else tables end end |
#selected_columns ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/json_q_l/executor.rb', line 13 def selected_columns if filtered_table.empty? "Nothing matched query" else parser.column_select.call(filtered_table) end end |
#tables ⇒ Object
31 32 33 |
# File 'lib/json_q_l/executor.rb', line 31 def tables parser.table_select.call(dataset) end |