From edee2c7b3bec824aa653b09d63aff06ab5542e06 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 5 Jun 2012 04:59:34 +0900 Subject: stop `to_s`ing method names Module#methods are Symbols in Ruby >= 1.9 --- activesupport/lib/active_support/core_ext/date_time/conversions.rb | 2 +- activesupport/lib/active_support/log_subscriber.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb index 19925198c0..13d659f52a 100644 --- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb @@ -39,7 +39,7 @@ class DateTime to_default_s end end - alias_method :to_default_s, :to_s unless (instance_methods(false) & [:to_s, 'to_s']).empty? + alias_method :to_default_s, :to_s if instance_methods(false).include?(:to_s) alias_method :to_s, :to_formatted_s # diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb index d2a6e1bd82..125e7b0e75 100644 --- a/activesupport/lib/active_support/log_subscriber.rb +++ b/activesupport/lib/active_support/log_subscriber.rb @@ -61,7 +61,7 @@ module ActiveSupport @@flushable_loggers = nil log_subscriber.public_methods(false).each do |event| - next if 'call' == event.to_s + next if :call == event notifier.subscribe("#{event}.#{namespace}", log_subscriber) end -- cgit v1.2.3 From 099639670a9a02ea2847117a541c4f48585951ad Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 5 Jun 2012 05:24:55 +0900 Subject: Symbol responds_to :upcase & :downcase in Ruby >= 1.9 --- activesupport/lib/active_support/log_subscriber.rb | 2 +- activesupport/lib/active_support/xml_mini.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb index 125e7b0e75..bea2ca17f1 100644 --- a/activesupport/lib/active_support/log_subscriber.rb +++ b/activesupport/lib/active_support/log_subscriber.rb @@ -114,7 +114,7 @@ module ActiveSupport # def color(text, color, bold=false) return text unless colorize_logging - color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) + color = self.class.const_get(color.upcase) if color.is_a?(Symbol) bold = bold ? BOLD : "" "#{bold}#{color}#{text}#{CLEAR}" end diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb index 88e18f6fff..88f9acb588 100644 --- a/activesupport/lib/active_support/xml_mini.rb +++ b/activesupport/lib/active_support/xml_mini.rb @@ -83,7 +83,7 @@ module ActiveSupport if name.is_a?(Module) @backend = name else - require "active_support/xml_mini/#{name.to_s.downcase}" + require "active_support/xml_mini/#{name.downcase}" @backend = ActiveSupport.const_get("XmlMini_#{name}") end end -- cgit v1.2.3 From 2635a29fec043076427d9fd19c330d2bcf7ab55d Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 5 Jun 2012 07:05:29 +0900 Subject: no need to to_s here. Both String and Symbol can be interpolated into String --- activesupport/lib/active_support/core_ext/module/delegation.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index fbef27c76a..39a1240c61 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -107,7 +107,6 @@ class Module raise ArgumentError, 'Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter).' end - to = to.to_s prefix, allow_nil = options.values_at(:prefix, :allow_nil) if prefix == true && to =~ /^[^a-z_]/ @@ -125,8 +124,6 @@ class Module line = line.to_i methods.each do |method| - method = method.to_s - # Attribute writer methods only accept one argument. Makes sure []= # methods still accept two arguments. definition = (method =~ /[^\]]=$/) ? 'arg' : '*args, &block' -- cgit v1.2.3