Class: Wallaby::ActiveRecord::ModelFinder

Inherits:
ModelFinder
  • Object
show all
Defined in:
lib/adapters/wallaby/active_record/model_finder.rb

Overview

Finder to return all the appropriate ActiveRecord models.

Instance Method Summary collapse

Instance Method Details

#allArray<Class>

Return a list of ActiveRecord::Base subclasses that aren’t one of the following types:

  1. abstract class

  2. anonymous class

  3. the HABTM relation class

Returns:

  • (Array<Class>)


13
14
15
16
17
18
19
20
21
# File 'lib/adapters/wallaby/active_record/model_finder.rb', line 13

def all
  ::ActiveRecord::Base.descendants.reject do |model_class|
    application_record?(model_class) ||
      model_class.abstract_class? ||
      anonymous?(model_class) ||
      model_class.name.index('HABTM') ||
      invalid_class_name?(model_class)
  end.sort_by(&:to_s)
end