Class: Wallaby::ActiveRecord::ModelFinder

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

Instance Method Summary collapse

Instance Method Details

#allObject



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

def all
  Rails.cache.fetch 'wallaby/active_record/model_finder' do
    base.subclasses.reject do |model_class|
      model_class.abstract_class? ||
      model_class.to_s.start_with?('#<') ||
      model_class.name == 'ActiveRecord::SchemaMigration' ||
      model_class.name.index('HABTM')
    end.sort_by &:to_s
  end
end

#baseObject



2
3
4
5
6
7
8
9
10
# File 'lib/adaptors/wallaby/active_record/model_finder.rb', line 2

def base
  Rails.cache.fetch 'wallaby/active_record/model_finder/base' do
    if defined? ::ApplicationRecord
      ::ApplicationRecord
    else
      ::ActiveRecord::Base
    end
  end
end