Class: BlazerJsonApi::QueriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/blazer_json_api/queries_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_authentication, #record_not_found, #render_errors

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/blazer_json_api/queries_controller.rb', line 7

def show
  @statement = @query.statement
  data_source = @query.data_source
  process_variables(@statement, data_source)
  result = Blazer.data_sources[data_source].run_statement(@statement)

  if result.error.present?
    render_errors(Array(result.error))
  else
    render json: BlazerJsonAPI::ResultToNestedJson.new(@statement, result).call
  end
end