lib/prosopite.rb in prosopite-1.3.3 vs lib/prosopite.rb in prosopite-1.4.0
- old
+ new
@@ -11,11 +11,12 @@
:stderr_logger,
:rails_logger,
:prosopite_logger,
:custom_logger,
:ignore_pauses,
- :backtrace_cleaner
+ :backtrace_cleaner,
+ :enabled
attr_accessor :allow_stack_paths,
:ignore_queries,
:min_n_queries
@@ -27,13 +28,25 @@
def backtrace_cleaner
@backtrace_cleaner ||= Rails.backtrace_cleaner
end
+ def enabled?
+ @enabled = true if @enabled.nil?
+
+ @enabled
+ end
+
+ def disabled?
+ !enabled?
+ end
+
def scan
tc[:prosopite_scan] ||= false
- return if scan?
+ if scan? || disabled?
+ return block_given? ? yield : nil
+ end
subscribe
tc[:prosopite_query_counter] = Hash.new(0)
tc[:prosopite_query_holder] = Hash.new { |h, k| h[k] = [] }
@@ -129,10 +142,11 @@
end
end
end
def fingerprint(query)
- if ActiveRecord::Base.connection.adapter_name.downcase.include?('mysql')
+ db_adapter = ActiveRecord::Base.connection.adapter_name.downcase
+ if db_adapter.include?('mysql') || db_adapter.include?('trilogy')
mysql_fingerprint(query)
else
begin
require 'pg_query'
rescue LoadError => e