Class: N1Finder::Adapters::ActiveRecordAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- N1Finder::Adapters::ActiveRecordAdapter
- Defined in:
- lib/n_1_finder/adapters/active_record_adapter.rb
Overview
Catches queries when using ActiveRecord
Constant Summary collapse
- MAIN_METHOD =
Method in ‘database_class` that we observe to find N+1 queries
Any activerecord connection adapter has a `exec_query` method http://api.rubyonrails.org/classes/ActiveRecord/Result.html
:exec_query
Constants inherited from BaseAdapter
BaseAdapter::MAIN_METHOD_ALIAS
Instance Attribute Summary
Attributes inherited from BaseAdapter
Class Method Summary collapse
-
.find_sql_params(params) ⇒ Hash
Searches for activerecord sql params in array.
Methods inherited from BaseAdapter
Constructor Details
This class inherits a constructor from N1Finder::Adapters::BaseAdapter
Class Method Details
.find_sql_params(params) ⇒ Hash
Searches for activerecord sql params in array
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/n_1_finder/adapters/active_record_adapter.rb', line 38 def find_sql_params(params) binds = params.find do |param| param.is_a?(Array) && param.first.is_a?(Array) && param.first.first.is_a?(ActiveRecord::ConnectionAdapters::Column) end || [] Hash[binds].each_with_object({}) do |(key, value), object| object[key.name] = value end end |