method
loaded?
Ruby on Rails latest stable (v7.1.3.2)
-
0 notes -
Class: Rails::GemDependency
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- 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