Class: Wallaby::Map::ModelClassMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/services/wallaby/map/model_class_mapper.rb

Overview

Go through the class list and generate a .map that uses the class’s model_class as the key.

Class Method Summary collapse

Class Method Details

.map(class_array) ⇒ ClassHash

Returns model class => descendant class.

Parameters:

  • class_array (Array<Class>)

Returns:

  • (ClassHash)

    model class => descendant class



9
10
11
12
13
14
15
16
# File 'lib/services/wallaby/map/model_class_mapper.rb', line 9

def self.map(class_array)
  (class_array || EMPTY_ARRAY).each_with_object(ClassHash.new) do |klass, hash|
    next if ModuleUtils.anonymous_class?(klass)
    next if klass.try(:base_class?) || klass.model_class.blank?

    hash[klass.model_class] = block_given? ? yield(klass) : klass
  end
end