15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/ae_page_objects/core/constant_resolver.rb', line 15
def load_missing_constant(from_mod, const_name)
path_for_constant = self.const_name_for(from_mod, const_name).underscore
application = "#{self.name}::Application".constantize
application.all_autoload_paths.each do |autoload_path|
file_path = File.join(autoload_path, "#{path_for_constant}.rb").sub(/(\.rb)?$/, ".rb")
if File.file?(file_path) && ! ActiveSupport::Dependencies.loaded.include?(File.expand_path(file_path))
ActiveSupport::Dependencies.require_or_load file_path
raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless ActiveSupport::Dependencies.local_const_defined?(from_mod, const_name)
return from_mod.const_get(const_name)
end
end
nil
end
|