Flowdock
method

loaded?

Importance_0
Ruby on Rails latest stable (v4.0.2) - 0 notes - Class: Rails::GemDependency

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

These similar methods exist in v4.0.2:

loaded?() public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

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
Register or log in to add new notes.