Class: Orthoses::Railties::Mixin

Inherits:
Object
  • Object
show all
Defined in:
lib/orthoses/railties/mixin.rb

Defined Under Namespace

Classes: MultiTracer

Instance Method Summary collapse

Constructor Details

#initialize(loader, callback:) ⇒ Mixin

MultiTracer



79
80
81
82
# File 'lib/orthoses/railties/mixin.rb', line 79

def initialize(loader, callback:)
  @loader = loader
  @callback = callback
end

Instance Method Details

#callObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/orthoses/railties/mixin.rb', line 84

def call
  multi_tracer = MultiTracer.new
  store = multi_tracer.trace do
    @loader.call
  end

  railties_mixin = Utils.new_store

  multi_tracer.captures.each do |base_mod, how, mods|
    base_mod_name = Utils.module_name(base_mod) or next
    mod_names = mods.map { |mod| Utils.module_name(mod) }.compact
    mod_names.each do |mod_name|
      store[base_mod_name].delete("#{how} #{mod_name}")
      railties_mixin[base_mod_name] << "#{how} #{mod_name}"
    end
  end

  @callback.call(railties_mixin)

  store
end