mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Call it compile_methods! and do the same on AM.
This commit is contained in:
parent
e1b51955f1
commit
6067d16200
4 changed files with 16 additions and 6 deletions
|
@ -18,6 +18,10 @@ module ActionMailer
|
|||
options.javascripts_dir ||= paths.public.javascripts.to_a.first
|
||||
options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
|
||||
|
||||
# make sure readers methods get compiled
|
||||
options.asset_path ||= nil
|
||||
options.asset_host ||= nil
|
||||
|
||||
ActiveSupport.on_load(:action_mailer) do
|
||||
include AbstractController::UrlFor
|
||||
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
|
||||
|
@ -25,5 +29,11 @@ module ActionMailer
|
|||
options.each { |k,v| send("#{k}=", v) }
|
||||
end
|
||||
end
|
||||
|
||||
initializer "action_mailer.compile_config_methods" do
|
||||
ActiveSupport.on_load(:action_mailer) do
|
||||
config.compile_methods! if config.respond_to?(:compile_methods!)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,9 +38,9 @@ module ActionController
|
|||
end
|
||||
end
|
||||
|
||||
config.after_initialize do
|
||||
initializer "action_controller.compile_config_methods" do
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
config.crystalize! if config.respond_to?(:crystalize!)
|
||||
config.compile_methods! if config.respond_to?(:compile_methods!)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,12 +10,12 @@ module ActiveSupport
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
class Configuration < ActiveSupport::InheritableOptions
|
||||
def crystalize!
|
||||
self.class.crystalize!(keys.reject {|key| respond_to?(key)})
|
||||
def compile_methods!
|
||||
self.class.compile_methods!(keys.reject {|key| respond_to?(key)})
|
||||
end
|
||||
|
||||
# compiles reader methods so we don't have to go through method_missing
|
||||
def self.crystalize!(keys)
|
||||
def self.compile_methods!(keys)
|
||||
keys.each do |key|
|
||||
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
||||
def #{key}; _get(#{key.inspect}); end
|
||||
|
|
|
@ -49,7 +49,7 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase
|
|||
assert !child.config.respond_to?(:bar)
|
||||
assert !child.new.config.respond_to?(:bar)
|
||||
|
||||
parent.config.crystalize!
|
||||
parent.config.compile_methods!
|
||||
assert_equal :foo, parent.config.bar
|
||||
assert_equal :foo, child.new.config.bar
|
||||
|
||||
|
|
Loading…
Reference in a new issue