Skip to content

Commit

Permalink
Privatize config_accessor as with attr_accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda committed Feb 5, 2015
1 parent 63f959d commit c2bfe6c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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`.

Expand Down
1 change: 1 addition & 0 deletions activesupport/lib/active_support/configurable.rb
Expand Up @@ -122,6 +122,7 @@ def config_accessor(*names)
send("#{name}=", yield) if block_given?
end
end
private :config_accessor
end

# Reads and writes attributes from a configuration <tt>OrderedHash</tt>.
Expand Down
8 changes: 8 additions & 0 deletions activesupport/test/configurable_test.rb
Expand Up @@ -111,6 +111,14 @@ class Child < Parent
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}"
Expand Down

0 comments on commit c2bfe6c

Please sign in to comment.