diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-06 08:49:38 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-06 08:49:38 -0700 |
commit | b4fb80cbdab118125df0d48e74b6818fe5ec65d5 (patch) | |
tree | b912b5041ee4a6a1ea7fdb3a743a7205b6bbd579 /actionpack | |
parent | 96123978ff5cbfe1ce56c2a3203b02007823335b (diff) | |
parent | ef9bbb87e8228940f768580a7d05d5feadec0d1e (diff) | |
download | rails-b4fb80cbdab118125df0d48e74b6818fe5ec65d5.tar.gz rails-b4fb80cbdab118125df0d48e74b6818fe5ec65d5.tar.bz2 rails-b4fb80cbdab118125df0d48e74b6818fe5ec65d5.zip |
Merge pull request #6645 from amatsuda/reduce_string_instance
Reduce number of String instance
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/abstract_controller/collector.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_controller/caching/pages.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/helper_test.rb | 32 |
3 files changed, 20 insertions, 20 deletions
diff --git a/actionpack/lib/abstract_controller/collector.rb b/actionpack/lib/abstract_controller/collector.rb index 81fb514770..492329c401 100644 --- a/actionpack/lib/abstract_controller/collector.rb +++ b/actionpack/lib/abstract_controller/collector.rb @@ -4,7 +4,7 @@ module AbstractController module Collector def self.generate_method_for_mime(mime) sym = mime.is_a?(Symbol) ? mime : mime.to_sym - const = sym.to_s.upcase + const = sym.upcase class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{sym}(*args, &block) # def html(*args, &block) custom(Mime::#{const}, *args, &block) # custom(Mime::HTML, *args, &block) @@ -19,7 +19,7 @@ module AbstractController protected def method_missing(symbol, &block) - mime_constant = Mime.const_get(symbol.to_s.upcase) + mime_constant = Mime.const_get(symbol.upcase) if Mime::SET.include?(mime_constant) AbstractController::Collector.generate_method_for_mime(mime_constant) @@ -29,4 +29,4 @@ module AbstractController end end end -end
\ No newline at end of file +end diff --git a/actionpack/lib/action_controller/caching/pages.rb b/actionpack/lib/action_controller/caching/pages.rb index dd4eddbe9a..73b8cd383c 100644 --- a/actionpack/lib/action_controller/caching/pages.rb +++ b/actionpack/lib/action_controller/caching/pages.rb @@ -110,7 +110,7 @@ module ActionController #:nodoc: gzip_level = options.fetch(:gzip, page_cache_compression) gzip_level = case gzip_level when Symbol - Zlib.const_get(gzip_level.to_s.upcase) + Zlib.const_get(gzip_level.upcase) when Fixnum gzip_level when false diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb index deb234b04f..248c81193e 100644 --- a/actionpack/test/controller/helper_test.rb +++ b/actionpack/test/controller/helper_test.rb @@ -109,13 +109,13 @@ class HelperTest < ActiveSupport::TestCase def test_helper_method assert_nothing_raised { @controller_class.helper_method :delegate_method } - assert master_helper_methods.include?('delegate_method') + assert master_helper_methods.include?(:delegate_method) end def test_helper_attr assert_nothing_raised { @controller_class.helper_attr :delegate_attr } - assert master_helper_methods.include?('delegate_attr') - assert master_helper_methods.include?('delegate_attr=') + assert master_helper_methods.include?(:delegate_attr) + assert master_helper_methods.include?(:delegate_attr=) end def call_controller(klass, action) @@ -160,16 +160,16 @@ class HelperTest < ActiveSupport::TestCase end def test_all_helpers - methods = AllHelpersController._helpers.instance_methods.map {|m| m.to_s} + methods = AllHelpersController._helpers.instance_methods # abc_helper.rb - assert methods.include?('bare_a') + assert methods.include?(:bare_a) # fun/games_helper.rb - assert methods.include?('stratego') + assert methods.include?(:stratego) # fun/pdf_helper.rb - assert methods.include?('foobar') + assert methods.include?(:foobar) end def test_all_helpers_with_alternate_helper_dir @@ -180,35 +180,35 @@ class HelperTest < ActiveSupport::TestCase @controller_class.helper :all # helpers/abc_helper.rb should not be included - assert !master_helper_methods.include?('bare_a') + assert !master_helper_methods.include?(:bare_a) # alternate_helpers/foo_helper.rb - assert master_helper_methods.include?('baz') + assert master_helper_methods.include?(:baz) end def test_helper_proxy - methods = AllHelpersController.helpers.methods.map(&:to_s) + methods = AllHelpersController.helpers.methods # Action View - assert methods.include?('pluralize') + assert methods.include?(:pluralize) # abc_helper.rb - assert methods.include?('bare_a') + assert methods.include?(:bare_a) # fun/games_helper.rb - assert methods.include?('stratego') + assert methods.include?(:stratego) # fun/pdf_helper.rb - assert methods.include?('foobar') + assert methods.include?(:foobar) end private def expected_helper_methods - TestHelper.instance_methods.map {|m| m.to_s } + TestHelper.instance_methods end def master_helper_methods - @controller_class._helpers.instance_methods.map {|m| m.to_s } + @controller_class._helpers.instance_methods end def missing_methods |