class Arproxy::QueryCallerLocationAnnotator::Proxy
Public Instance Methods
execute(sql, name=nil)
click to toggle source
Calls superclass method
# File lib/arproxy/query_caller_location_annotator/proxy.rb, line 6 def execute(sql, name=nil) return super(sql, name) unless sql =~ /^(SELECT|INSERT|UPDATE|DELETE)/ location = query_caller_location if location.present? super("#{sql} /* #{location} */", name) else super(sql, name) end end
Private Instance Methods
annotate_location_regexp()
click to toggle source
# File lib/arproxy/query_caller_location_annotator/proxy.rb, line 32 def annotate_location_regexp @annotate_location_regexp ||= /\A#{Regexp.quote(annotate_match_location)}/.freeze end
annotate_match_location()
click to toggle source
# File lib/arproxy/query_caller_location_annotator/proxy.rb, line 28 def annotate_match_location @annotate_match_location ||= ::Rails.root.join('app').to_s.freeze end
query_caller_location()
click to toggle source
# File lib/arproxy/query_caller_location_annotator/proxy.rb, line 19 def query_caller_location location = caller_locations.find { |l| annotate_location_regexp.match(l.absolute_path) } if location.nil? nil else "app#{location.absolute_path.gsub(annotate_match_location, '')}:#{location.lineno} `#{location.label}`" end end