Class: SqlTracer::Helper
- Inherits:
-
Object
- Object
- SqlTracer::Helper
- Defined in:
- lib/sql_tracer/helper.rb
Class Method Summary collapse
- .disable_console_output? ⇒ Boolean
- .output_select_sql_disabled? ⇒ Boolean
- .should_output_sql?(sql) ⇒ Boolean
- .should_skip_lib? ⇒ Boolean
- .should_skip_sql_by_keywords?(sql) ⇒ Boolean
- .should_skip_url_by_keywords?(url) ⇒ Boolean
- .shoule_skip_path_by_keywords?(path) ⇒ Boolean
Class Method Details
.disable_console_output? ⇒ Boolean
29 30 31 |
# File 'lib/sql_tracer/helper.rb', line 29 def disable_console_output? @console_output_disabled ||= config.get(:SQL_TRACER_CONSOLE_OUTPUT_DISABLED) end |
.output_select_sql_disabled? ⇒ Boolean
6 7 8 |
# File 'lib/sql_tracer/helper.rb', line 6 def output_select_sql_disabled? @output_select_sql_disabled ||= config.get(:SQL_TRACER_OUTPUT_SELECT_SQL_DISABLED) end |
.should_output_sql?(sql) ⇒ Boolean
33 34 35 36 37 |
# File 'lib/sql_tracer/helper.rb', line 33 def should_output_sql?(sql) reg = 'insert|update|delete' reg << '|select' unless Helper.output_select_sql_disabled? return sql =~ /^\s*(#{reg})\s/i && !Helper.should_skip_sql_by_keywords?(sql) end |
.should_skip_lib? ⇒ Boolean
10 11 12 |
# File 'lib/sql_tracer/helper.rb', line 10 def should_skip_lib? @should_skip_lib ||= config.get(:SQL_TRACER_SKIP_LIB_PATH) end |
.should_skip_sql_by_keywords?(sql) ⇒ Boolean
14 15 16 17 |
# File 'lib/sql_tracer/helper.rb', line 14 def should_skip_sql_by_keywords?(sql) @sql_keywords ||= config.get(:SQL_TRACER_SQL_FILTER) @sql_keywords.present? && @sql_keywords.any? { |keyword| sql.include?(keyword) } end |
.should_skip_url_by_keywords?(url) ⇒ Boolean
19 20 21 22 |
# File 'lib/sql_tracer/helper.rb', line 19 def should_skip_url_by_keywords?(url) @url_keywords ||= config.get(:SQL_TRACER_URL_FILTER) @url_keywords.present? && @url_keywords.any? { |keyword| url.include?(keyword) } end |
.shoule_skip_path_by_keywords?(path) ⇒ Boolean
24 25 26 27 |
# File 'lib/sql_tracer/helper.rb', line 24 def shoule_skip_path_by_keywords?(path) @path_keywords ||= build_path_filter @path_keywords.present? && @path_keywords.any? { |keyword| path.include?(keyword) } end |