Class: NOne::Runner
- Inherits:
-
Object
- Object
- NOne::Runner
- Defined in:
- lib/n_one/runner.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(whitelist: [], ignore_names: [], stacktrace_sanitizer: nil) ⇒ Runner
constructor
Instantiation.
- #scan(&block) ⇒ Object
- #scan!(&block) ⇒ Object
Constructor Details
#initialize(whitelist: [], ignore_names: [], stacktrace_sanitizer: nil) ⇒ Runner
Instantiation
12 13 14 15 16 |
# File 'lib/n_one/runner.rb', line 12 def initialize(whitelist: [], ignore_names: [], stacktrace_sanitizer: nil) @whitelist = ['active_record/validations/uniqueness'] + whitelist @ignore_names = ignore_names @stacktrace_sanitizer = stacktrace_sanitizer end |
Instance Method Details
#scan(&block) ⇒ Object
18 19 20 21 22 |
# File 'lib/n_one/runner.rb', line 18 def scan(&block) init_store record_sql(&block) detect_n_plus_ones end |
#scan!(&block) ⇒ Object
24 25 26 27 28 |
# File 'lib/n_one/runner.rb', line 24 def scan!(&block) report = scan(&block) raise NPlusOneDetected, report unless report.empty? end |