mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix setting simple values to the new config.x
Previously setting simple values to the config.x object resulted in the following: config.x.super_debugger = true config.x.super_debugger #=> {} Which was against the examples showed in the changelog/release notes.
This commit is contained in:
parent
e2066818e8
commit
2f7ac9cdcc
4 changed files with 24 additions and 13 deletions
|
@ -84,7 +84,7 @@ Please refer to the [Changelog][railties] for detailed changes.
|
|||
# config/environments/production.rb
|
||||
config.x.payment_processing.schedule = :daily
|
||||
config.x.payment_processing.retries = 3
|
||||
config.x.super_debugger = true
|
||||
config.x.super_debugger = true
|
||||
```
|
||||
|
||||
These options are then available through the configuration object:
|
||||
|
@ -93,7 +93,6 @@ Please refer to the [Changelog][railties] for detailed changes.
|
|||
Rails.configuration.x.payment_processing.schedule # => :daily
|
||||
Rails.configuration.x.payment_processing.retries # => 3
|
||||
Rails.configuration.x.super_debugger # => true
|
||||
Rails.configuration.x.super_debugger.not_set # => nil
|
||||
```
|
||||
|
||||
([Commit](https://github.com/rails/rails/commit/611849772dd66c2e4d005dcfe153f7ce79a8a7db))
|
||||
|
|
|
@ -22,14 +22,13 @@
|
|||
# config/environments/production.rb
|
||||
config.x.payment_processing.schedule = :daily
|
||||
config.x.payment_processing.retries = 3
|
||||
config.x.super_debugger = true
|
||||
config.x.super_debugger = true
|
||||
|
||||
These configuration points are then available through the configuration object:
|
||||
|
||||
Rails.configuration.x.payment_processing.schedule # => :daily
|
||||
Rails.configuration.x.payment_processing.retries # => 3
|
||||
Rails.configuration.x.super_debugger # => true
|
||||
Rails.configuration.x.super_debugger.not_set # => nil
|
||||
|
||||
*DHH*
|
||||
|
||||
|
|
|
@ -155,15 +155,21 @@ module Rails
|
|||
def annotations
|
||||
SourceAnnotationExtractor::Annotation
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
class Custom
|
||||
class Custom #:nodoc:
|
||||
def initialize
|
||||
@configurations = Hash.new
|
||||
end
|
||||
|
||||
|
||||
def method_missing(method, *args)
|
||||
@configurations[method] ||= ActiveSupport::OrderedOptions.new
|
||||
if method =~ /=$/
|
||||
@configurations[$`.to_sym] = args.first
|
||||
else
|
||||
@configurations.fetch(method) {
|
||||
@configurations[method] = ActiveSupport::OrderedOptions.new
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,13 +3,20 @@ require 'application/configuration/base_test'
|
|||
class ApplicationTests::ConfigurationTests::CustomTest < ApplicationTests::ConfigurationTests::BaseTest
|
||||
test 'access custom configuration point' do
|
||||
add_to_config <<-RUBY
|
||||
config.x.resque.inline_jobs = :always
|
||||
config.x.resque.timeout = 60
|
||||
config.x.payment_processing.schedule = :daily
|
||||
config.x.payment_processing.retries = 3
|
||||
config.x.super_debugger = true
|
||||
config.x.hyper_debugger = false
|
||||
config.x.nil_debugger = nil
|
||||
RUBY
|
||||
require_environment
|
||||
|
||||
assert_equal :always, Rails.configuration.x.resque.inline_jobs
|
||||
assert_equal 60, Rails.configuration.x.resque.timeout
|
||||
assert_nil Rails.configuration.x.resque.nothing
|
||||
x = Rails.configuration.x
|
||||
assert_equal :daily, x.payment_processing.schedule
|
||||
assert_equal 3, x.payment_processing.retries
|
||||
assert_equal true, x.super_debugger
|
||||
assert_equal false, x.hyper_debugger
|
||||
assert_equal nil, x.nil_debugger
|
||||
assert_nil x.i_do_not_exist.zomg
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue