aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2015-02-06 01:18:23 +0900
committerAkira Matsuda <ronnie@dio.jp>2015-02-06 01:18:23 +0900
commit4ca1dda0bfc9ba76c5da114ab47399a385ab059e (patch)
tree16a67a976f0f9c6dc1378994f92aa9f4d69f6dba
parent63f959d21b6b60fbb1571115fa9f54e64b503a79 (diff)
parentc2bfe6cbc8cab9caeab418472a1e12a3ed3e75e2 (diff)
downloadrails-4ca1dda0bfc9ba76c5da114ab47399a385ab059e.tar.gz
rails-4ca1dda0bfc9ba76c5da114ab47399a385ab059e.tar.bz2
rails-4ca1dda0bfc9ba76c5da114ab47399a385ab059e.zip
Merge pull request #18610 from amatsuda/privatize_config_accessor
config_accessor should better not be a public method, as with Ruby's attr_accessor
-rw-r--r--activesupport/CHANGELOG.md4
-rw-r--r--activesupport/lib/active_support/configurable.rb1
-rw-r--r--activesupport/test/configurable_test.rb8
3 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 2a4ed394a0..77c4b29980 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -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
`Time.now` and `Date.today`.
diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb
index 3dd44e32d8..8256c325af 100644
--- a/activesupport/lib/active_support/configurable.rb
+++ b/activesupport/lib/active_support/configurable.rb
@@ -122,6 +122,7 @@ module ActiveSupport
send("#{name}=", yield) if block_given?
end
end
+ private :config_accessor
end
# Reads and writes attributes from a configuration <tt>OrderedHash</tt>.
diff --git a/activesupport/test/configurable_test.rb b/activesupport/test/configurable_test.rb
index ef847fc557..5d22ded2de 100644
--- a/activesupport/test/configurable_test.rb
+++ b/activesupport/test/configurable_test.rb
@@ -111,6 +111,14 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase
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)
methods = object.public_methods.map(&:to_s)
assert methods.include?(method.to_s), "Expected #{methods.inspect} to include #{method.to_s.inspect}"