This object defines a path from which Constants can be loaded.
Methods
Public Class methods
Create a new load path with the filesystem path
[ show source ]
# File vendor/rails/activesupport/lib/active_support/dependencies.rb, line 138
138: def initialize(root) @root = root end
Public Instance methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/dependencies.rb, line 156
156: def const_name_to_file_name(name)
157: name.to_s.underscore + '.rb'
158: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/dependencies.rb, line 160
160: def const_name_to_module_name(name)
161: name.to_s.underscore
162: end
Return nil if the path does not exist, or the path to a directory if the path leads to a module, or the path to a file if it leads to an object.
[ show source ]
# File vendor/rails/activesupport/lib/active_support/dependencies.rb, line 142
142: def filesystem_path(path, allow_module=true)
143: fs_path = [@root]
144: fs_path += path[0..-2].collect {|name| const_name_to_module_name name}
145:
146: if allow_module
147: result = File.join(fs_path, const_name_to_module_name(path.last))
148: return result if File.directory? result # Return the module path if one exists
149: end
150:
151: result = File.join(fs_path, const_name_to_file_name(path.last))
152:
153: return File.file?(result) ? result : nil
154: end