File: require_dependency.rb

package info (click to toggle)
rails 2%3A7.2.2.1%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 43,352 kB
  • sloc: ruby: 349,799; javascript: 30,703; yacc: 46; sql: 43; sh: 29; makefile: 27
file content (28 lines) | stat: -rw-r--r-- 1,029 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module ActiveSupport::Dependencies::RequireDependency
  # <b>Warning:</b> This method is obsolete. The semantics of the autoloader
  # match Ruby's and you do not need to be defensive with load order anymore.
  # Just refer to classes and modules normally.
  #
  # Engines that do not control the mode in which their parent application runs
  # should call +require_dependency+ where needed in case the runtime mode is
  # +:classic+.
  def require_dependency(filename)
    filename = filename.to_path if filename.respond_to?(:to_path)

    unless filename.is_a?(String)
      raise ArgumentError, "the file name must be either a String or implement #to_path -- you passed #{filename.inspect}"
    end

    if abspath = ActiveSupport::Dependencies.search_for_file(filename)
      require abspath
    else
      require filename
    end
  end

  # We could define require_dependency in Object directly, but a module makes
  # the extension apparent if you list ancestors.
  Object.prepend(self)
end