8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/oasis/dependencies.rb', line 8
def require_or_load(file, const_path=nil)
super(file, const_path) unless defined? RAILS_ROOT
file_loaded = false
plugin_file_name, app_file_name = "", ""
file_name, base_name = (file), (file)
if file_name =~ /_(helper|controller)?$/
type = file_name.split("_").last
Oasis::Logger.trace "searching for #{type} named '#{file_name}'"
Oasis.apps.each do |app|
plugin_file_name = File.expand_path(File.join(app.directory, "app", "#{type}s", base_name))
Oasis::Logger.trace "checking engine '#{app.name}' for '#{file_name}' (#{plugin_file_name})"
break if File.file? "#{plugin_file_name}.rb"
end
else
Oasis::Logger.trace "searching for models named '#{file_name}'"
Oasis.apps.each do |app|
plugin_file_name = File.expand_path(File.join(app.directory, "app", "models", base_name))
Oasis::Logger.trace "checking engine '#{app.name}' for '#{file_name}' (#{plugin_file_name})"
break if File.file? "#{plugin_file_name}.rb"
end
end
if File.file?("#{plugin_file_name}.rb")
Oasis::Logger.debug "loading '#{file_name}' from an engine."
file_loaded = true if super(plugin_file_name, const_path)
end
app_file_name = File.join(RAILS_ROOT, "app", "#{type||"model"}s", base_name)
if File.file? "#{app_file_name}.rb"
Oasis::Logger.trace "loading from application: #{file_name}"
file_loaded = true if super(app_file_name, const_path)
else
Oasis::Logger.trace "file '#{file_name}' not found in application"
end
file_loaded || super(file, const_path)
end
|