method
loaded?
Ruby on Rails latest stable (v3.2.13)
-
0 notes -
Class: Rails::GemDependency
- 1.0.0
- 1.1.0
- 1.1.1
- 1.1.6
- 1.2.0
- 1.2.6
- 2.0.0
- 2.0.1
- 2.0.3
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.2 (0)
- 2.3.8 (0)
- 3.0.0
- 3.0.5
- 3.0.7
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.3
- 3.2.8
- 3.2.13
- What's this?
loaded?()
public
Hide source
# File railties/lib/rails/gem_dependency.rb, line 162 def loaded? @loaded ||= begin if vendor_rails? true elsif specification.nil? false else # check if the gem is loaded by inspecting $" # specification.files lists all the files contained in the gem gem_files = specification.files # select only the files contained in require_paths - typically in bin and lib require_paths_regexp = Regexp.new("^(#{specification.require_paths*'|'})/") gem_lib_files = gem_files.select { |f| require_paths_regexp.match(f) } # chop the leading directory off - a typical file might be in # lib/gem_name/file_name.rb, but it will be 'require'd as gem_name/file_name.rb gem_lib_files.map! { |f| f.split('/', 2)[1] } # if any of the files from the above list appear in $", the gem is assumed to # have been loaded !(gem_lib_files & $").empty? end end end


