Class: DatabasePlumber::LeakFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/database_plumber/leak_finder.rb

Defined Under Namespace

Classes: InvalidModelError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ LeakFinder

Returns a new instance of LeakFinder.



12
13
14
15
16
# File 'lib/database_plumber/leak_finder.rb', line 12

def initialize(options)
  @ignored_models = (options[:ignored_models] || []) + IGNORED_AR_INTERNALS
  @ignored_adapters = options[:ignored_adapters] || []
  @model_thresholds = options[:model_thresholds] || {}
end

Class Method Details

.inspect(options = {}) ⇒ Object



8
9
10
# File 'lib/database_plumber/leak_finder.rb', line 8

def self.inspect(options = {})
  new(options).inspect
end

Instance Method Details

#inspectObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/database_plumber/leak_finder.rb', line 18

def inspect
  filtered_models.each_with_object({}) do |model, results|
    records = count_for(model)
    if records > threshold_for(model)
      results[model.to_s] = records
      mop_up(model)
    end
    results
  end
end