Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove String#constantize deps

  • Loading branch information...
commit ed61c3b64012f4e17eb25d42d5b962e13c69b47a 1 parent cfc9439
@jeremy jeremy authored
View
2  activesupport/lib/active_support/dependencies.rb
@@ -153,7 +153,7 @@ def const_missing(const_name, nesting = nil)
nesting.each do |namespace|
begin
- return Dependencies.load_missing_constant namespace.constantize, const_name
+ return Dependencies.load_missing_constant Inflector.constantize(namespace), const_name
rescue NoMethodError then raise
rescue NameError => e
error ||= e
View
15 activesupport/test/core_ext/hash_ext_test.rb
@@ -940,13 +940,14 @@ def test_to_xml_dups_options
end
def test_expansion_count_is_limited
- expected = {
- 'ActiveSupport::XmlMini_REXML' => 'RuntimeError',
- 'ActiveSupport::XmlMini_Nokogiri' => 'Nokogiri::XML::SyntaxError',
- 'ActiveSupport::XmlMini_NokogiriSAX' => 'RuntimeError',
- 'ActiveSupport::XmlMini_LibXML' => 'LibXML::XML::Error',
- 'ActiveSupport::XmlMini_LibXMLSAX' => 'LibXML::XML::Error',
- }[ActiveSupport::XmlMini.backend.name].constantize
+ expected =
+ case ActiveSupport::XmlMini.backend.name
+ when 'ActiveSupport::XmlMini_REXML'; RuntimeError
+ when 'ActiveSupport::XmlMini_Nokogiri'; Nokogiri::XML::SyntaxError
+ when 'ActiveSupport::XmlMini_NokogiriSAX'; RuntimeError
+ when 'ActiveSupport::XmlMini_LibXML'; LibXML::XML::Error
+ when 'ActiveSupport::XmlMini_LibXMLSAX'; LibXML::XML::Error
+ end
assert_raise expected do
attack_xml = <<-EOT

2 comments on commit ed61c3b

@neerajdotname
Collaborator

Is there an effort to get away from string#constantize in favor of Inflector.constantize ?

@jeremy
Owner

Encouraging as few interdependencies as reasonable so cherry-picking is cheap and lightweight.

Please sign in to comment.
Something went wrong with that request. Please try again.