-
-
Save yorickpeterse/0434416575e399649100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
models = Rails.root.join('app', 'models').to_s | |
ar_regex = / | |
i?where # where, iwhere | |
| find(_by)? | |
| pluck | |
| select\((:|\[) # select(:id), select([:foo, :bar]) | |
| reorder | |
| exists\? | |
| update(_attributes|_all)? # update, update_attributes, update_all | |
| save | |
| destroy | |
| create | |
| joins | |
| unscoped | |
| order(_by)? # order, order_by | |
/x | |
ActiveRecord::Base.subclasses.each do |klass| | |
klass.public_methods(false).each do |name| | |
method = klass.public_method(name) | |
source = method.source_location | |
if source and source[0].start_with?(models) and method.source =~ ar_regex | |
config.instrument_method(klass, name) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment