跳至内容 跳至搜索
方法
A
B
E
N
R
T
W

类公共方法

new()

# File railties/lib/rails/railtie/configuration.rb, line 8
def initialize
  @@options ||= {}
end

实例公共方法

after_initialize(&block)

最后可配置的代码块要运行。在框架初始化后调用。

# File railties/lib/rails/railtie/configuration.rb, line 70
def after_initialize(&block)
  ActiveSupport.on_load(:after_initialize, yield: true, &block)
end

after_routes_loaded(&block)

在应用程序路由加载后调用。

# File railties/lib/rails/railtie/configuration.rb, line 75
def after_routes_loaded(&block)
  ActiveSupport.on_load(:after_routes_loaded, yield: true, &block)
end

app_generators()

这允许您从 Railties 修改应用程序的生成器。

app_generators 上设置的值将成为应用程序的默认值,除非应用程序覆盖它们。

# File railties/lib/rails/railtie/configuration.rb, line 47
def app_generators
  @@app_generators ||= Rails::Configuration::Generators.new
  yield(@@app_generators) if block_given?
  @@app_generators
end

app_middleware()

这允许您从引擎修改应用程序的中件件。

您在 app_middleware 上执行的所有操作都将在应用程序定义后并创建 default_middlewares 时在应用程序上重放

# File railties/lib/rails/railtie/configuration.rb, line 39
def app_middleware
  @@app_middleware ||= Rails::Configuration::MiddlewareStackProxy.new
end

before_configuration(&block)

第一个可配置的代码块要运行。在运行任何初始化器之前调用。

# File railties/lib/rails/railtie/configuration.rb, line 54
def before_configuration(&block)
  ActiveSupport.on_load(:before_configuration, yield: true, &block)
end

before_eager_load(&block)

第三个可配置的代码块要运行。如果 config.eager_load 设置为 false,则不运行。

# File railties/lib/rails/railtie/configuration.rb, line 60
def before_eager_load(&block)
  ActiveSupport.on_load(:before_eager_load, yield: true, &block)
end

before_initialize(&block)

第二个可配置的代码块要运行。在框架初始化后调用。

# File railties/lib/rails/railtie/configuration.rb, line 65
def before_initialize(&block)
  ActiveSupport.on_load(:before_initialize, yield: true, &block)
end

eager_load_namespaces()

所有被热加载的命名空间

# File railties/lib/rails/railtie/configuration.rb, line 18
def eager_load_namespaces
  @@eager_load_namespaces ||= []
end

respond_to?(name, include_private = false)

# File railties/lib/rails/railtie/configuration.rb, line 90
def respond_to?(name, include_private = false)
  super || @@options.key?(name.to_sym)
end

to_prepare(&blk)

定义通用回调,在 after_initialize 之前运行。对 Rails::Railtie 子类有用。

# File railties/lib/rails/railtie/configuration.rb, line 86
def to_prepare(&blk)
  to_prepare_blocks << blk if blk
end

to_prepare_blocks()

数组to_prepare 定义的回调。

# File railties/lib/rails/railtie/configuration.rb, line 80
def to_prepare_blocks
  @@to_prepare_blocks ||= []
end

watchable_dirs()

添加应该被监控以进行更改的目录。哈希的键应该是目录,值应该是每个目录中要匹配的扩展名的数组。

# File railties/lib/rails/railtie/configuration.rb, line 30
def watchable_dirs
  @@watchable_dirs ||= {}
end

watchable_files()

添加应该被监控以进行更改的文件。

# File railties/lib/rails/railtie/configuration.rb, line 23
def watchable_files
  @@watchable_files ||= []
end