1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #18610 from amatsuda/privatize_config_accessor

config_accessor should better not be a public method, as with Ruby's attr_accessor
This commit is contained in:
Akira Matsuda 2015-02-06 01:18:23 +09:00
commit 4ca1dda0bf
3 changed files with 13 additions and 0 deletions

View file

@ -1,3 +1,7 @@
* config_accessor became a private method, as with Ruby's attr_accessor.
*Akira Matsuda*
* `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as * `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as
`Time.now` and `Date.today`. `Time.now` and `Date.today`.

View file

@ -122,6 +122,7 @@ module ActiveSupport
send("#{name}=", yield) if block_given? send("#{name}=", yield) if block_given?
end end
end end
private :config_accessor
end end
# Reads and writes attributes from a configuration <tt>OrderedHash</tt>. # Reads and writes attributes from a configuration <tt>OrderedHash</tt>.

View file

@ -111,6 +111,14 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase
end end
end end
test 'the config_accessor method should not be publicly callable' do
assert_raises NoMethodError do
Class.new {
include ActiveSupport::Configurable
}.config_accessor :foo
end
end
def assert_method_defined(object, method) def assert_method_defined(object, method)
methods = object.public_methods.map(&:to_s) methods = object.public_methods.map(&:to_s)
assert methods.include?(method.to_s), "Expected #{methods.inspect} to include #{method.to_s.inspect}" assert methods.include?(method.to_s), "Expected #{methods.inspect} to include #{method.to_s.inspect}"