Module: Adva::Engine::SlicedModels

Included in:
Initializations
Defined in:
lib/adva/engine/sliced_models.rb

Instance Method Summary collapse

Instance Method Details

#preload_sliced_modelsObject

TODO while preloading seems to work fine, it slows the dev mode down quite a bit. should be replace with an approace which lazyloads sliced models in Dependencies maybe an after-load hook in Dependencies would work.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/adva/engine/sliced_models.rb', line 8

def preload_sliced_models
  types = %w(helpers controllers models views)
  paths = types.map { |type| self.paths.app.send(type).to_a.first }
  pattern = %r((?:#{paths.join('|')})/((?:\w+/)*\w+_slice(?:.\w+)*).rb$)

  Dir["{#{paths.join(',')}}/**/*.rb"].each do |filename|
    if filename =~ pattern
      begin
        require_dependency $1.gsub(%r(_slice), '')
        require_dependency filename
      rescue LoadError
      end
    end
  end
end