Class: ForestAdminRpcAgent::Routes::NativeQuery

Inherits:
BaseRoute
  • Object
show all
Defined in:
lib/forest_admin_rpc_agent/routes/native_query.rb

Instance Method Summary collapse

Methods inherited from BaseRoute

#build_rails_response, #register_rails, #register_sinatra, #registered

Constructor Details

#initializeNativeQuery

Returns a new instance of NativeQuery.



6
7
8
# File 'lib/forest_admin_rpc_agent/routes/native_query.rb', line 6

def initialize
  super('rpc-native-query', 'post', 'rpc_native_query')
end

Instance Method Details

#handle_request(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/forest_admin_rpc_agent/routes/native_query.rb', line 10

def handle_request(args)
  return {} unless args[:params]['connection_name'] && args[:params]['query']

  connection_name = args[:params]['connection_name']
  query = args[:params]['query']
  binds = args[:params]['binds'] || []
  datasource = ForestAdminRpcAgent::Facades::Container.datasource

  datasource.execute_native_query(connection_name, query, binds)
end