Sha256: 11b99b74fcab9e44e64ae632aaef83bd7f7013f921500f2e62424f33fad4b419

Contents?: true

Size: 1.06 KB

Versions: 322

Compression:

Stored size: 1.06 KB

Contents

require "active_support/inflector/methods"
require "active_support/lazy_load_hooks"

module ActiveSupport
  module Autoload
    @@autoloads = {}
    @@under_path = nil
    @@at_path = nil
    @@eager_autoload = false

    def autoload(const_name, path = @@at_path)
      full = [self.name, @@under_path, const_name.to_s, path].compact.join("::")
      location = path || Inflector.underscore(full)

      if @@eager_autoload
        @@autoloads[const_name] = location
      end
      super const_name, location
    end

    def autoload_under(path)
      @@under_path, old_path = path, @@under_path
      yield
    ensure
      @@under_path = old_path
    end

    def autoload_at(path)
      @@at_path, old_path = path, @@at_path
      yield
    ensure
      @@at_path = old_path
    end

    def eager_autoload
      old_eager, @@eager_autoload = @@eager_autoload, true
      yield
    ensure
      @@eager_autoload = old_eager
    end

    def self.eager_autoload!
      @@autoloads.values.each { |file| require file }
    end

    def autoloads
      @@autoloads
    end
  end
end

Version data entries

322 entries across 278 versions & 28 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies/autoload.rb
activesupport-3.2.22.5 lib/active_support/dependencies/autoload.rb
activesupport-3.2.22.4 lib/active_support/dependencies/autoload.rb
activesupport-3.2.22.3 lib/active_support/dependencies/autoload.rb
activesupport-3.2.22.2 lib/active_support/dependencies/autoload.rb
activesupport-3.2.22.1 lib/active_support/dependencies/autoload.rb
classiccms-0.7.5 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/dependencies/autoload.rb
classiccms-0.7.4 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/dependencies/autoload.rb
classiccms-0.7.3 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/dependencies/autoload.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies/autoload.rb
activesupport-3.2.22 lib/active_support/dependencies/autoload.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.12/lib/active_support/dependencies/autoload.rb
activesupport-3.2.21 lib/active_support/dependencies/autoload.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/dependencies/autoload.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/dependencies/autoload.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies/autoload.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies/autoload.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/dependencies/autoload.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/dependencies/autoload.rb
activesupport-3.2.20 lib/active_support/dependencies/autoload.rb