Class: Motor::Query

Inherits:
ApplicationRecord show all
Defined in:
app/models/motor/query.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

audited

Instance Method Details

#result(variables_hash = {}) ⇒ Object Also known as: run


18
19
20
21
22
23
# File 'app/models/motor/query.rb', line 18

def result(variables_hash = {})
  result = Motor::Queries::RunQuery.call!(self, variables_hash: variables_hash)
  column_names = result.columns.pluck(:name)

  result.data.map { |row| column_names.zip(row).to_h }
end