Class: PhenomenalRails::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/phenomenal_rails/loader.rb

Class Method Summary collapse

Class Method Details

.autoload_paths(path, paths = []) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/phenomenal_rails/loader.rb', line 3

def autoload_paths(path,paths=[])
  scan_dir(path) do |filepath, entry|
    if File.directory?(filepath)
      if (filepath.match(/.*\/controllers/) ||
        filepath.match(/.*\/models/) ||
        filepath.match(/.*\/helpers/))      
        paths.push(filepath)
      end
      autoload_paths(filepath,paths)        
    end
  end
  paths
end

.prepare(loading = false) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/phenomenal_rails/loader.rb', line 17

def prepare(loading=false)
  phen_defined_contexts.reverse.each do |context|
    if !context.forgotten && (!context.persistent || !Rails.configuration.cache_classes)
      while phen_context_active?(context) do
        phen_deactivate_context(context) 
      end
      if !Rails.configuration.cache_classes
        phen_forget_context(context)
      end
    end
  end

  if !Rails.configuration.cache_classes || loading
    Phenomenal::Feature.middleware.clear_activition_conditions
    load_files(File.expand_path(PhenomenalRails::PATH,Rails.root))
  end
end