Skip to content
Browse files

simplifies ActiveRecord::ExplainSubscriber [José Valim & Xavier Noria]

  • Loading branch information...
1 parent d59bfeb commit 7f3ce35e1947c31233263a2cd48740646f5585b3 @fxn fxn committed Dec 4, 2011
Showing with 6 additions and 8 deletions.
  1. +6 −8 activerecord/lib/active_record/explain_subscriber.rb
View
14 activerecord/lib/active_record/explain_subscriber.rb
@@ -1,13 +1,11 @@
-module ActiveRecord
- class ExplainSubscriber < ActiveSupport::LogSubscriber
- def sql(event)
- ActiveRecord::Base.collect_queries_for_explain(event.payload)
- end
+require 'active_support/notifications'
- def logger
- ActiveRecord::Base.logger
+module ActiveRecord
+ class ExplainSubscriber
+ def call(*args)
+ ActiveRecord::Base.collect_queries_for_explain(args.last)
end
- attach_to :active_record
+ ActiveSupport::Notifications.subscribe("sql.active_record", new)
end
end

0 comments on commit 7f3ce35

Please sign in to comment.
Something went wrong with that request. Please try again.