Class: Wallaby::Map::ModeMapper

Inherits:
Object
  • Object
show all
Extended by:
Classifier
Defined in:
lib/services/wallaby/map/mode_mapper.rb

Overview

Go through each Wallaby::Mode (e.g. ActiveRecord/Her) and find out all the model classes respectively. Then a hash (Model => Wallaby::Mode) is constructed to tell Wallaby which Wallaby::Mode to use for a given model.

Class Method Summary collapse

Methods included from Classifier

class_name_of, to_class

Class Method Details

.execute(class_names) ⇒ WallabyClassHash

Parameters:

Returns:

  • (WallabyClassHash)


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/services/wallaby/map/mode_mapper.rb', line 14

def self.execute(class_names)
  ClassHash.new.tap do |hash|
    next if class_names.blank?

    class_names.each_with_object(hash) do |mode_name, map|
      mode_name.model_finder.new.all.each do |model_class| # rubocop:disable Rails/FindEach
        map[model_class] = mode_name
      end
    end
  end
end